C# 关闭开启进程
2013-01-30 17:56
295 查看
#region 方法 /// <summary> /// 关闭应用程序 /// </summary> /// <param name="ArrayProcessName">应用程序名之间用‘,’分开</param> private void CloseApp(string ArrayProcessName) { string[] processName = ArrayProcessName.Split(','); foreach (string appName in processName) { Process[] localByNameApp = Process.GetProcessesByName(appName);//获取程序名的所有进程 if (localByNameApp.Length > 0) { foreach (var app in localByNameApp) { if (!app.HasExited) { app.Kill();//关闭进程 } } } } } /// <summary> /// 开启进程 /// </summary> /// <param name="ArrayFolderPath">需要开启进程文件夹的路径,多个路径用‘,’隔开;eg:d:\test,e:\temp</param> private void StartApp(string ArrayFolderPath) { string[] foldersNamePath = ArrayFolderPath.Split(','); foreach (string folderNamePath in foldersNamePath) { GetFolderApp(folderNamePath); } } /// <summary> /// 递归遍历文件夹内所有的exe文件,此方法可以进一步扩展为其它的后缀文件 /// </summary> /// <param name="folderNamePath">文件夹路径</param> private void GetFolderApp(string folderNamePath) { string[] foldersPath = Directory.GetDirectories(folderNamePath); foreach (string folderPath in foldersPath) { GetFolderApp(folderPath); } string[] filesPath = Directory.GetFiles(folderNamePath); foreach (string filePath in filesPath) { FileInfo fileInfo = new FileInfo(filePath); //开启后缀为exe的文件 if (fileInfo.Extension.Equals(".exe")) { Process.Start(filePath); } } } #endregion
相关文章推荐
- C# 关闭EXCEL进程
- C#重新启动时,关闭较早的进程
- C#开启关闭串口,发送数据
- c#关闭系统进程以及如何调用cmd并执行命令
- .Net关闭开启进程
- C# 关闭进程的时候总是捕捉到System.Threading.ThreadAbortException: 正在中止线程
- 通过gpio控制一个进程开启或关闭
- c#关闭系统进程以及如何调用cmd并执行命令
- C# 进程启动与关闭
- C# 关闭登录窗体,进入主窗体后,主窗体关闭,程序进程仍在运行的问题
- c# 关闭进程
- C# 事件与委托___窗口间的相互开启与关闭
- Hbase 开启关闭遇到的一些问题记录 HregionServer 进程关不掉
- [原创]C#生成Excel,彻底关闭进程
- C# 如何关闭,释放Excel进程
- C# 开启一个新进程,IE,打开一个URL,第一次总失败,刷新一下就好了
- C#用Com组件解析Excel文件 然后删除Excel 并且彻底关闭Excel进程(公司实战项目经验)
- C#:程序关闭了,为什么在后台还有进程存在?(转载)
- C#彻底关闭Excel进程excel.exe
- C# 启动关闭.exe进程(转)