FileStream with locked file

后端 未结 4 2054
悲&欢浪女
悲&欢浪女 2020-12-11 14:50

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          


        
4条回答
  •  死守一世寂寞
    2020-12-11 15:41

    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.

提交回复
热议问题