private static bool SeventZPrcess(string arguments) { Process process = new Process(); process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; //隐藏压缩窗口 process.StartInfo.FileName = DirEx.CurrentDir() + "7z.exe"; process.StartInfo.CreateNoWindow = false; process.StartInfo.Arguments = arguments; process.Start(); process.WaitForExit(); if (process.HasExited) { int iExitCode = process.ExitCode; process.Close(); if (iExitCode != 0 && iExitCode != 1) { return(false); } } return(true); }
/// <summary>保存到配置文件中去</summary> /// <param name="filename">文件名</param> public override void Save(string filename) { if (filename.IsNullOrWhiteSpace()) { filename = DirEx.CurrentDir() + ConfigFile; } if (filename.IsNullOrWhiteSpace()) { throw new ApplicationException($"未指定{typeof(TConfig).Name}的配置文件路径!"); } ConcurrentDictionary <string, Ident> idents = ConfigHelper.InitIdents(current); foreach (var ident in idents.Values) { if (ident.Section.IsNullOrEmpty()) { ident.Section = "Setup"; } } ConfigHelper.SaveConfigValue(Current, idents); List <string> strs = new List <string> { ";<!--" + Description + "-->", "" }; Dictionary <string, List <Ident> > listidents = new Dictionary <string, List <Ident> >(); foreach (var ident in idents.Values) { string section = ident.IsList ? ident.Section + "-" + ident.Key : ident.Section; if (!listidents.ContainsKey(section)) { listidents.Add(section, new List <Ident>()); } listidents[section].Add(ident); } foreach (var values in listidents) { strs.Add("[" + values.Key + "]"); SortedList <int, Ident> slist = new SortedList <int, Ident>(); foreach (var ident in values.Value) { slist.Add(ident.Index, ident); } foreach (var ident in slist.Values) { if (!ident.Description.IsNullOrEmpty()) { strs.Add(";<!--" + ident.Description + "-->"); } if (ident.IsList) { for (int i = 0; i < ident.Values.Count; i++) { strs.Add("Value" + i + "=" + ident.Values[i]); } } else { strs.Add(ident.Key + "=" + ident.Value); } } strs.Add(""); } listidents.Clear(); DirEx.CreateDir(Path.GetDirectoryName(filename)); File.WriteAllLines(filename, strs.ToArray(), IniBase.IniEncoding); }