I have a program that start another program. In the second program, I try to delete a File.
If I run directly the second program, no problem, the file get deleted. But if I start the second program from the first program, I get a System.UnauthorizedAccessException.
My guess is that the second program doesn’t get all the access of the first program.
I tried many suggestions I found but none of them worked.
Adding Process.StartInfo.Verb = “runas” didnt work.
Adding a manifest file didnt work either (or I did it wrong, not sure)
I set the .exe of the second file to “Run as Administrator” and it didn’t work.
Now, how do I fix this?
The first program left the file open, so the second program cannot delete it.
You need to close the file in the first program.