I think the documentation is actually talking about the input and output buffers used by FileStream
("FileStream buffers input and output for better performance.").
If you use the .NET library reference source, you can see that the SafeFileHandle
property actually flushes all buffers (i.e. caches) and resets their positions back to zero. It doesn't touch the variable that holds the information about how far the file has really been read (or written). The Position
property in turn, always uses that variable (plus the buffer /cache offsets) to return it's value.
The important part seems to be this:
This allows the file to be moved or the stream position to be reset by another stream using the SafeFileHandle returned by this property.
Basically, SafeFileHandle
guarantees you, that you can use the return value (e.g. with SetFilePointer
) to access the file and have no issues with the (eventual) caching of the FileStream
instance.