I'm trying to grok streams - my world is C# but I suspect the principles are general.
I understand the general principle of reading/writing bytes from/to a store. However, what I don't understand, specifically in a read scenario, is what has happened when you've created an instance of a stream (FileStream, for instance) but have not yet invoked any read methods.
e.g.
var fileStream = new FileStream( "Test.txt", FileMode.Open )
At this point the fileStream.Length
property is available to me. This leads me to wonder the following:
- Has the FileStream class already read all the bytes in the file and ascertained the length of the file?
- Has the file been able to report its length to the FileStream?
- Is the file now already loaded into memory and the filestream is offering that up to me in a chunked fashion?
- Am I reading into memory the file's bytes at the time I call the read methods?