zoukankan      html  css  js  c++  java
  • C# 关闭开启进程

    #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
    
  • 相关阅读:
    pyspark创建RDD数据、RDD转DataFrame以及保存
    pyspark将DataFrame转成table以及操作sql语句
    pyspark读取textfile形成DataFrame以及查询表的属性信息
    sql-lab闯关之20-22
    sql-lib闯关之lesson17-19
    sql-lab闯关之13-16
    sql-lab闯关之11-12
    sql-lib闯关之lesson8-10
    sql-lab闯关之7
    sql-lib闯关之5-6
  • 原文地址:https://www.cnblogs.com/guozhe/p/2883454.html
Copyright © 2011-2022 走看看