public string getString(string key) { TStringList list = getFile(); foreach (var line in list) { string[] parts = line.Split(new string[] { splitter }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2 && key == parts[0]) { return(parts[1]); } } return(null); }
public bool hasKey(string key) { TStringList list = getFile(); foreach (var line in list) { string[] parts = line.Split(new string[] { splitter }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2 && key == parts[0]) { return(true); } } return(false); }
public TStringList getFile() { TStringList list = new TStringList(); if (!File.Exists(filename)) { Directory.CreateDirectory(Path.GetFullPath(filename)); list.SaveToFile(filename); } else { list.LoadFromFile(this.filename); } return(list); }
public void setString(string key, string value) { TStringList list = getFile(); for (int i = 0; i < list.Count; i++) { string[] parts = list[i].Split(new string[] { splitter }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 2 && key == parts[0]) { list[i] = key + splitter + value.Replace(splitter, SplitReplacement); list.SaveToFile(filename); return; } } }
public void setList(string key, TStringList value) { setString(key, String.Join(";", value.ToArray())); }