public static string GetCheckFirstKeyFromSection(string filePath, string _section, string saveDefaultKey = null) { string keyReturn = null; IniFile ini = new IniFile(filePath); var sect = ini.GetSection(_section); LogUser Log = new LogUser(); if (sect == null) { sect = ini.AddSection(_section); if (saveDefaultKey != null) { sect.AddKey(saveDefaultKey); } ini.SaveShowMessage(); } if (sect.Keys.Count == 0 & saveDefaultKey != null) { sect.AddKey(saveDefaultKey); ini.SaveShowMessage(); } Log.Out(); SetFirstKeyFromSection(sect, ref keyReturn); return(keyReturn); }
private static void CheckTestsPass_CopyWithError(string file, string oldPath, string msg) { LogUser log = new LogUser(); try { string newPath = PublicData.PathDeacreaseByFolder(PublicData.LogsCheckPassPath); newPath = Path.Combine(newPath, "#Fails_checkpass"); newPath = Path.Combine(newPath, PublicData.placeNumber); if (!Directory.Exists(newPath)) { Directory.CreateDirectory(newPath); } newPath = Path.Combine(newPath, file); string contentFile = string.Empty; Ex.Try(() => { File.Copy(oldPath, newPath, true); contentFile = File.ReadAllText(newPath); }); File.WriteAllText(newPath, string.Format("{1}{0}{0}{2}", Environment.NewLine, msg, contentFile)); } finally { log.Out(); } }
public static void ShowMessage(Exception ex, string msg = null, bool logTo = true) { if (logTo) { LogUser login = new LogUser(); LogException(msg + ex.ToString()); login.Out(); } ex.Show(msg); }
private static void CreateLog(string incPath, string msg) { LogUser log = new LogUser(); string path = PublicData.PathDeacreaseByFolder(PublicData.LogsCheckPassPath); path = CreatePath(path, incPath, PublicData.placeNumber); string fullPath = Path.Combine(path, DateTime.Now.ToString("yyyy.MM.dd; HH.mm.ss")); string contentFile = string.Empty; File.WriteAllText(fullPath, string.Format("{1}{0}{0}{2}", Environment.NewLine, msg, contentFile)); log.Out(); }