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

猜你喜欢

转载自blog.csdn.net/BYH371256/article/details/120429729
今日推荐