In most cases, the stream is an HTTP stream and the Stream.CanSeek value will be set to false. Hence, you should read the data from the stream in a forward direction only. Also, do not make any assumptions regarding the stream length as shown in the examples.
For an example, refer to SharePointClient.GetDownloadStream and SharePointClient.GetDownloadStreamAsync.