今天在工作中碰到需要重启在运行中的应用程序,现在写出来跟大家分享: using System.Diagnostics; 或者: if(MessageBox.Show("要重新启动嘛?","提示", MessageBoxButtons.YesNoCancel, 推荐使用: Application.Restart();
string strAppFileName=Process.GetCurrentProcess().MainModule.FileName;
Process myNewProcess=new Process();
myNewProcess.StartInfo.FileName=strAppFileName;
myNewProcess.StartInfo.WorkingDirectory=Application.ExecutablePath;
myNewProcess.Start();
Application.Exit();
MessageBoxIcon.Question) == DialogResult.Yes)
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().Location);
C#实现重启应用程序
最新推荐文章于 2025-05-12 07:00:00 发布