提交记录新增Core/Librarys/ProcessHelper.cs+36 −0看文件
| @@ -0,0 +1,36 @@ | ||
| 1 | 新增:using System; | |
| 2 | 新增:using System.Collections.Generic; | |
| 3 | 新增:using System.Diagnostics; | |
| 4 | 新增:using System.Linq; | |
| 5 | 新增:using System.Text; | |
| 6 | 新增:using System.Threading.Tasks; | |
| 7 | 新增: | |
| 8 | 新增:namespace Core.Librarys | |
| 9 | 新增:{ | |
| 10 | 新增: public class ProcessHelper | |
| 11 | 新增: { | |
| 12 | 新增: public static bool Run(string filename, string[] args) | |
| 13 | 新增: { | |
| 14 | 新增: try | |
| 15 | 新增: { | |
| 16 | 新增: string arguments = ""; | |
| 17 | 新增: foreach (string arg in args) | |
| 18 | 新增: { | |
| 19 | 新增: arguments += $"\"{arg}\" "; | |
| 20 | 新增: } | |
| 21 | 新增: arguments = arguments.Trim(); | |
| 22 | 新增: Process process = new Process(); | |
| 23 | 新增: ProcessStartInfo startInfo = new ProcessStartInfo(filename, arguments); | |
| 24 | 新增: process.StartInfo = startInfo; | |
| 25 | 新增: process.Start(); | |
| 26 | 新增: return true; | |
| 27 | 新增: } | |
| 28 | 新增: catch (Exception ex) | |
| 29 | 新增: { | |
| 30 | 新增: Logger.Error(ex.ToString()); | |
| 31 | 新增: return false; | |
| 32 | 新增: } | |
| 33 | 新增: | |
| 34 | 新增: } | |
| 35 | 新增: } | |
| 36 | 新增:} | |

