How to relaunch running application
i am working on an win mobile application . I am running application in background using
e.Cancle = true;
Now i need to relaunch same instance of that application so that i can off that applic开发者_JAVA技巧ation .
can any one tell me ... how to do this?
If the application needs to restart itself this may help you :
http://msdn.microsoft.com/en-us/library/system.windows.forms.application.restart.aspx
You don't actually need to be running a winforms application for this to work - you just need to make sure the System.Windows.Forms DLL is present.
PS. i couldn't get this working for WPF - but I don't actually remember the exact reason right now
You need to:
1) Stop application(Kill process) http://msdn.microsoft.com/en-us/library/system.diagnostics.process.kill.aspx or Exit application http://msdn.microsoft.com/en-us/library/system.windows.forms.application.exit(v=vs.71).aspx
2) Run application again(Start process) http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start(v=vs.71).aspx
Also you may use Restart
method http://msdn.microsoft.com/en-us/library/system.windows.forms.application.restart.aspx
Which way you will choose depends no the your particular situation.
This might do it.
System.Diagnostics.Process.Start(Application.ExecutablePath);
Close();
精彩评论