private void buttonCreateAutoCustomFile_Click(object sender, EventArgs e) { Ex.Catch(() => { var fileEnd = Setting.FileEndOptions.Get(new SavingManager()).Value; var filePath = Path.Combine(PublicData.FolderConfigPath, $"autostart.{fileEnd}"); //if ( File.Exists(filePath) ) throw new IOException($"Файл уже существует.\n{filePath}"); var section = new IniFile(filePath, true).AddSection(PublicData.constAutoName); section.AddKey("code").SetValue(" "); section.AddKey("regex").SetValue(".+"); section.IniFile.SaveShowMessage(); }); VisualRefresh(); }
static bool loadKeyForm(Action[] func, string mes, string[] incArray, string name = "", bool color = false) { logger.Trace($"Reader Started! (isStopReader=false)"); PublicData.isStopReader = false; bool retry = false; bool final = false; var reader = Code.PortReaderOld(); do { PublicData.pred_answer = ""; if (func != null) { foreach (var f in func) { if (f != null) { f(); Thread.Sleep(400); } } } var form = new KeyForm(mes, incArray, name, color); var result = form.ShowDialog(); switch (result) { case DialogResult.Retry: retry = true; break; case DialogResult.OK: return(true); default: return(false); } }while (retry); Code.StopPortReader().Wait(); Ex.Catch(() => reader.Wait()); return(final); }
private static IniFile.IniSection FindSectionInFolderBySection(string section, string path = null) { string fileEnd = new SavingManager().Key(Setting.FileEndOptions).Value; if (path == null) { path = PublicData.FolderConfigPath; } FileInfo[] files = new DirectoryInfo(path).GetFiles("*" + fileEnd); foreach (var tabFile in files) { string filePath = Path.Combine(tabFile.DirectoryName, tabFile.Name); IniFile ini = new IniFile(); Ex.Catch(() => ini.Load(filePath)); var findSection = ini.GetSection(section); if (findSection != null) { return(findSection); } } return(null); }