I'm using a third party library in my .NET Core console application. The library is generating a text file and the library keeps the file locked (possibly a static instance is kept somewhere inside the library) until the process exits.
I need to postprocess the locked file after I have done calling the third-party library functions. Of course, currently I cannot do that because of the infamous "The file is being used by another process" exception (in my case, it's actually the same process).
What would be the easiest and safest approach to gain access to the locked file from the same console application?
Fortunately, I know for sure there will be no parallel threads running and no more other access to this file - once the library is done writing, it is done, although the file remains locked. So, I could safely do whatever I like with the file if only I could "break the lock" or invent some trick to unload that third party library and get the lock released.