C#实现重启应用程序

C#实现重启应用程序 收藏
using    System.Diagnostics;  
   string    strAppFileName=Process.GetCurrentProcess().MainModule.FileName;  
   Process    myNewProcess=new    Process();  
   myNewProcess.StartInfo.FileName=strAppFileName;  
   myNewProcess.StartInfo.WorkingDirectory=Application.ExecutablePath;  
   myNewProcess.Start();  
   Application.Exit();  

或者

if    (    MessageBox.Show("要重新启动嘛?","提示", MessageBoxButtons.YesNoCancel,  
   MessageBoxIcon.Question)    ==    DialogResult.Yes)  
   System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location); 

posted @ 2010-05-21 11:39  梦想(胡大利)  阅读(1566)  评论(1编辑  收藏  举报