WHAT I HAVE:
Visual Basic 2019, WinForms, .NET Framework 4.6.1+
MY PROBLEM:
I've learned how to design an app so that it can use mspaint.exe to edit an Image for the app user, as follows:
ImageInstance.Save(FileName) 'FileName is a temporary file to be passed to mspaint
Process.Start("mspaint.exe", """" & FileName & """").WaitForExit()
ImageInstance.FromFile(FileName)
There are some problems with this approach, however. While it works like a charm the very 1st time the code is executed in a run, if the above code is executed again within a single program run--say, if the user wants to edit the image again--then I get an ExternalException on the Image.Save method the 2nd time around. (You can't save an image back to the same file it's created from! And if I try to delete FileName first, I get a "used by another process" exception.) Also, even if I get past that, the mspaint app itself won't let a user save changes upon being fired up the 2nd time around, citing "sharing issues"! (BTW, if I try to start mspaint using a Process instance, rather than the static method, then mspaint balks the very 1st time the user tries to save changes in it.)
I need a reliable way for a program to repeatedly pass an image to an external app such as mspaint, where the user can then use the app to make changes to the image, and then have the program retrieve the saved changes to the image--all during the same run of the "primary" program. Please give me an answer ASAP, in VB.NET, and in a general-purpose form that will work for working with a typical graphics-editor app (like mspaint)--or any other external app being run within my apps, for that matter. And keep it as simple as possible!
PS. If I can't solve this problem, then I could have serious difficulty being able to pass data back and forth to other apps for those apps to modify while my own apps are running and using them.