WPF应用程序如何重启当前的Application



3个方法都差不多,都是先重启一个进程,然后关闭当前的进程。

[csharp] view plain copy print ?
  1. // Restart current process Method 1  
  2. System.Windows.Forms.Application.Restart();  
  3. Application.Current.Shutdown();  
  4.   
  5. // Restart current process Method 2  
  6. System.Reflection.Assembly.GetEntryAssembly();  
  7. string startpath = System.IO.Directory.GetCurrentDirectory();  
  8. System.Diagnostics.Process.Start(startpath + "\\xxx.exe");  
  9. Application.Current.Shutdown();  
  10.   
  11. // Restart current process Method 3  
  12. Process p = new Process();  
  13. p.StartInfo.FileName = System.AppDomain.CurrentDomain.BaseDirectory + "xxx.exe";  
  14. p.StartInfo.UseShellExecute = false;  
  15. p.Start();  
  16. Application.Current.Shutdown();  




转自http://blog.csdn.net/hustypf/article/details/12613555

你可能感兴趣的:(WPF应用程序如何重启当前的Application)