C# 重啓程序的方法

C# 中一般重啓exe程序有以下三種方法:

方法一:使用Restart()方法

System.Windows.Forms.Application.Restart();
Application.Current.Shutdown();

// 方法二:使用System.Diagnostics.Process.Start()

System.Reflection.Assembly.GetEntryAssembly();
string startpath = System.IO.Directory.GetCurrentDirectory();
System.Diagnostics.Process.Start(startpath + “\\xxx.exe”);
Application.Current.Shutdown();

// 方法三:使用Process方式

Process p = new Process();
p.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + “xxx.exe”;
p.StartInfo.UseShellExecute = false;
p.Start(); 

Application.Current.Shutdown();

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章