Aaron Ackerman said:
Can you have more than one instance of your app running at a time? If so,
then you could try the following:
1) Have the EXE rename its own file (example: MyApp.EXE becomes MyApp.BAK).
This can be accomplished with the System.IO.File.MoveTo method.
2) Copy the new EXE to the app's directory. Since you renamed the original
file, this copy should now work.
3) Launch the new EXE with the System.Diagnostics.Process.Start method
In C#, this might look something like this:
//------------------------------------------------
// Renames the current file
File.Move(@"RenameTest.exe", @"RenameTest.bak");
// Change the next line to get the new file from it's real location (such as
a network folder or a URL)
File.Copy(@"C:\RenameTest.exe", @"RenameTest.exe");
// Starts the app as a new instance
Process.Start("RenameTest.exe");
//------------------------------------------------
I tried this in a console app, and all seemed to go well. You might need to
put in code to clean up the backup file if it exists.
Usually, the kind of process is handled by a bootstrap .exe. You create a
small app that handles copying over new versions of the main app . This
small bootstrap app is the one that you launch each time you want to execute
the main program.