Change the name of my own executable

  • Thread starter Thread starter thebrath
  • Start date Start date
T

thebrath

Hi,
I am trying to rename my own executable while executing as an
Automatic update feature. It is possible to rename the "programm.exe"
by FileExplorer but the File.Move method throws an Exception.

I know it is impossible to delete the own Executable but it shoud be
possible to rename it.

Best Regards
Volker Thebrath
 
Volker,

As you indicated, you will receive a System.IO.IOException with a message
similar to "The process can not access the file '\Program
Files\SelfDeleteTest\SelfDeleteTest.exe' because it is being used by another
process." if you attempt to perform a File.Delete() on it.

However, the following works successfully:
File.Move(@"\Program Files\SelfDeleteTest\SelfDeleteTest.exe", @"\Program
Files\SelfDeleteTest\SelfDeleteTest.old");

What exeception are you receiving when you attempt a File.Move() ?

Additionally, you may wish to reconsider using an architecture that
leverages a dedicated updater applet. Some examples:
http://msdn2.microsoft.com/en-us/library/aa446487.aspx
http://www.ftponline.com/vsm/2006_11/magazine/features/jgavilan
 
Back
Top