Basically, I'm running into trouble "working around" an API I have no control over which is locking a file when it shouldn't be.
The method from the API looks like this:
public static bool Upload(string fileName) { ... } // I have no ability to look inside this
It behaves like it's reading the file directly off the disk, and not placing the file into memory before hand.
This is a problem because it's written so poorly that whenever it fails at uploading, it fails to release the file lock. This means I have to start my application over again in order to release the file - which is a huge pain in production!
The only work-around I could think of was making an individual copy of the file (~ few MB at most) for each firmware upload instance. This could get it working, but then leaves me with the problem of deleting each file manually afterwards (since the file lock would be open as long as the app is, I couldn't do it in code)
Is there any workaround I can do that wouldn't create a ton of issues? My only thought is creating a separate C# class to hold the static upload function, then find some way to dispose the class and resources after it runs. Any ideas?
EDIT: It's a 3rd party API that uses proprietary code to talk to a microcontroller - so unless I want to bit-spy and re-create all the back and forth packets, it looks like rewriting the original function is a no-go.