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();

 

posted @ 2022-05-13 09:41  willamyao  阅读(1691)  评论(0)    收藏  举报