G
Guest
Hello
I have a Windows.Forms application program running in kiosk mode on Windows
CE, and I want to add support for updating the program with a new version
located on a USB memory stick.
By updating I mean replacing the entire .exe file.
I have tried different approaches using the System.Diagnostics.Process and
System.IO.File
classes. Regardless of approach, the running .exe file (or process) must
somehow be stopped such that the lock placed on the .exe file is removed,
making it possible to delete or overwrite the file.
How can this be done?
One of my approaches is as follows:
1) Assume the running application program is located on
\ Hard Disk \ myApp_v1.exe
2) Insert a USB pen with two programs:
\ USB Disk \ myApp_v2.exe
\ USB Disk \ UpdateAssistant.exe
3) In 'myApp_v1.exe' then execute the following code:
Process updateProcess= new Process();
updateProcess.StartInfo.FileName = @"\ USB Disk \ UpdateAssistant.exe";
updateProcess.Start();
//Terminate myApp_v1.exe which has only 1 Form (Window)
this.Close();
Application.Exit();
4) In 'UpdateAssistant.exe' execute the following code from the constructor:
// Try deleting 'myApp_v1.exe' to see if lock is removed
File.Delete( @ "\ Hard Disk \ myApp_v1.exe");
This results in an IOException, meaning that 'myApp_v1.exe' is still in use
and therefore locked.
Is it not sufficiant to call 'this.Close()' followed by 'Application.Exit()'
to terminate a Windows.Forms application?
I have a Windows.Forms application program running in kiosk mode on Windows
CE, and I want to add support for updating the program with a new version
located on a USB memory stick.
By updating I mean replacing the entire .exe file.
I have tried different approaches using the System.Diagnostics.Process and
System.IO.File
classes. Regardless of approach, the running .exe file (or process) must
somehow be stopped such that the lock placed on the .exe file is removed,
making it possible to delete or overwrite the file.
How can this be done?
One of my approaches is as follows:
1) Assume the running application program is located on
\ Hard Disk \ myApp_v1.exe
2) Insert a USB pen with two programs:
\ USB Disk \ myApp_v2.exe
\ USB Disk \ UpdateAssistant.exe
3) In 'myApp_v1.exe' then execute the following code:
Process updateProcess= new Process();
updateProcess.StartInfo.FileName = @"\ USB Disk \ UpdateAssistant.exe";
updateProcess.Start();
//Terminate myApp_v1.exe which has only 1 Form (Window)
this.Close();
Application.Exit();
4) In 'UpdateAssistant.exe' execute the following code from the constructor:
// Try deleting 'myApp_v1.exe' to see if lock is removed
File.Delete( @ "\ Hard Disk \ myApp_v1.exe");
This results in an IOException, meaning that 'myApp_v1.exe' is still in use
and therefore locked.
Is it not sufficiant to call 'this.Close()' followed by 'Application.Exit()'
to terminate a Windows.Forms application?