Describe the bug
The method DataStreamFactory.FromFile doesn't behave as FileStream and it doesn't check if the file exists when opening one for reading. It will throw the exception later when the user tries to access to the data.
To Reproduce
Call DataStreamFactory.FromFile(path, FileOpenMode.Read) where path points to a file that doesn't exist yet.
No exception is thrown.
Use the stream, a exception is thrown.
Expected behavior
There is a FileNotFoundException as FileStream does in the method that creates the DataStream. The reason is that we use internally a LazyFileStream so we don't open the file immediately but still we should check that.
Additional context
These are the cases where FileStream will throw an exception:
FileNotFoundException
The file cannot be found, such as when mode is FileMode.Truncate or FileMode.Open, and the file specified by path does not exist. The file must already exist in these modes.
It should be applied to the modes Append and Read from FileOpenMode.
Describe the bug The method
DataStreamFactory.FromFile
doesn't behave asFileStream
and it doesn't check if the file exists when opening one for reading. It will throw the exception later when the user tries to access to the data.To Reproduce
DataStreamFactory.FromFile(path, FileOpenMode.Read)
wherepath
points to a file that doesn't exist yet.Expected behavior There is a
FileNotFoundException
asFileStream
does in the method that creates theDataStream
. The reason is that we use internally aLazyFileStream
so we don't open the file immediately but still we should check that.Additional context These are the cases where
FileStream
will throw an exception:It should be applied to the modes
Append
andRead
fromFileOpenMode
.