////// 杀死进程 /// private void KillProcesses() { var cfn = GetAppsettingStr("checkin-filefolder-name"); var ofn = GetAppsettingStr("outmoney-filefolder-name"); var ifn = GetAppsettingStr("inmoney-filefolder-name"); foreach (var p in Process.GetProcesses()) { if (p.ProcessName == cfn || p.ProcessName == ofn || p.ProcessName == ifn) { p.Kill(); } } } ////// 启动进程 /// private void StartProcesses() { var list = new List(); var cfn = GetAppsettingStr("checkin-filefolder") + GetAppsettingStr("checkin-filefolder-name"); var ofn = GetAppsettingStr("outmoney-filefolder") + GetAppsettingStr("outmoney-filefolder-name"); var ifn = GetAppsettingStr("inmoney-filefolder") + GetAppsettingStr("inmoney-filefolder-name"); list.Add(ofn); list.Add(ifn); list.Add(cfn); foreach (var li in list) { Process.Start(li + ".exe"); } }
再加上从app.config 文件里获取数据
http://192.168.1.155:8013/DataService/WebService/Interface/UpgradeFile.asmx
是这样获取app.config数据的:
////// 获取配置文件里appsettings的数据 /// /// ///public string GetAppsettingStr(string str) { var appReader = new AppSettingsReader(); return appReader.GetValue(str, typeof(string)).ToString(); }