c# - How can I work around a bad API function that leaves a locked file on failure? -
Basically, I am running "working" around an API, which I have no control on which a file is locked. Should not be.
The method of the API looks like this:
public static bulk upload (string filename) {...} // I have no capability to look inside it This behaves as if it is reading directly from the disc, and does not keep the file in memory before hand
This is a problem because It has been badly written that it fails to issue file lock whenever it fails to upload is. This means that I have to start my application again to release the file - which is a big pain in production!
I could only think of the work-making a personal copy of the file (for each firmware upload example ~ at least MB) it can work, but then I can use every file Manually passes the problem of later deletion (because the file lock will be open until the app is not, I can not do it in the code)
Is there an alternative solution that I can do? Can not be the issue of a ton Can not My only idea is to create a separate C # class to capture the stable upload function, then after running a few ways to deal with the class and the resources it runs any thoughts?
Edit : This is a third party API that uses proprietary code to talk to the microcontroller - so long as I do not want bit-detective and all the back Re-create the packet next, it seems that there is no way to rewrite the original function.