Is it possible to bypass a file lock in C# when another thread/process is unecessarily using an exclusive lock?

前端 未结 7 1036
半阙折子戏
半阙折子戏 2021-01-11 12:07

Is there a way to bypass or remove the file lock held by another thread without killing the thread?

I am using a third-party library in my app that is performing

相关标签:
7条回答
  • 2021-01-11 13:10

    I do think that this is a problem that can be solved with c++. It is annoying but at least it works (as discussed here: win32 C/C++ read data from a "locked" file)

    The steps are:

    1. Open the file before the third-library with fsopen and the _SH_DENYNO flag
    2. Open the file with the third-library
    3. Read the file within your code

    You may be interested in these links as well:

    1. Calling c++ from c# (Possible to call C++ code from C#?)
    2. The inner link from this post with a sample (http://blogs.msdn.com/b/borisj/archive/2006/09/28/769708.aspx)
    0 讨论(0)
提交回复
热议问题