FileStream with locked file

后端 未结 4 2057
悲&欢浪女
悲&欢浪女 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:39

    I've used the following which works, however should use with caution as file can be modified while you have it open by another process.

    FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read,FileShare.ReadWrite);
    

提交回复
热议问题