public static bool SetCfgValue(string key, string value) { List <string> lst = new FileIo().ReaderFiles(Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, filename)); if (lst != null) { for (int i = 0; i < lst.Count; i++) { if (lst[i].Length == 0) { continue; } string[] st = lst[i].Split('='); if (st.Length == 1) { continue; } if (st[0] == key) { lst[i] = key + "=" + value; new FileIo().WriterFile(Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, filename), lst.ToArray()); return(true); } } } else { lst = new List <string>(); } lst.Add(key + "=" + value); new FileIo().WriterFile(Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, filename), lst.ToArray()); return(false); }
public static string GetCfgValue(string key) { string str = null; List <string> lst = new FileIo().ReaderFiles(Path.Combine(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase, filename)); if (lst != null) { foreach (string s in lst) { int index = s.IndexOf('='); if (index <= 0) { continue; } string k = s.Substring(0, index); string v = s.Substring(index + 1, s.Length - index - 1); if (k == key) { str = v; break; } } } return(str); }