重启程序的四种方法
其中方法一,是我最常用的方法,其他几个方法很好用过。
方法一:使用Restart()方法
Application.Exit();
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
方法二:使用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();