예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        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;
                }
            }
        }
예제 #5
0
 public void setList(string key, TStringList value)
 {
     setString(key, String.Join(";", value.ToArray()));
 }