I am wondering if it's possible to get a readonly FileStream to a locked file? I now get an exception when I try to read the locked file.
using (FileStream stream = new FileStream("path", FileMode.Open))
Thanks!
Right-click on the file. In the menu that appears, select Lock File. To unlock, right-click the file and select Unlock File.
You should try another constructor. They are documented at MSDN.
This one looks like a bet:
FileStream Constructor (String, FileMode, FileAccess, FileShare)
MSDN Link
FileAccess
A constant that determines how the file can be accessed by the FileStream object. This gets the CanRead and CanWrite properties of the FileStream object. CanSeek is true if path specifies a disk file.
FileShare
A constant that determines how the file will be shared by processes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With