Stream.Length only works on Stream implementations where seeking is available. You can usually check to see if Stream.CanSeek is true. Many streams, since they’re being streamed, are of a nature where it’s impossible to know the length in advance.
If you must know the length, you may need to actually buffer the entire stream, loading it into memory in advance.