Using C# is it possible to test if a lock is held on a file

后端 未结 5 1573
我寻月下人不归
我寻月下人不归 2021-01-22 17:51

BACKGROUND: I use an offset into a file and the Filestream lock/unlock menthods to control read/write access. I am using the following code to test if a lock i

5条回答
  •  失恋的感觉
    2021-01-22 18:27

    My goal is to eliminate the try/catch block

    Remember, the file system is volatile: just because your file is in one state for one operation doesn't mean it will be in the same state for the next operation. You have to be able to handle exceptions from the file system.

提交回复
热议问题