What I'm trying to do is once the user closes my program, I want the program to automatically delete the exe file. This is what I have but when I close the program I get an error that the path is not accessible, and I assume it's because at the second it is being used and can't delete.
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
string path = Application.ExecutablePath;
File.Delete(path);
}
If anyone knows how to either execute the code once the program is fully closed or how to modify this code to make it do that, I'd appreciate it a lot.