Пример #1
0
        public SettingsReader(string appName, string fileName)
        {
            _settings = new Dictionary <string, string>();

            string path = Path.Combine(SettingsShared.GetMyAppDataDir(appName), fileName);

            if (!File.Exists(path))
            {
                return;
            }

            using (StreamReader sr = new StreamReader(path, Encoding.UTF8)) {
                string line, name, val;
                int    pos;

                while ((line = sr.ReadLine()) != null)
                {
                    pos = line.IndexOf('=');
                    if (pos != -1)
                    {
                        name = line.Substring(0, pos);
                        val  = line.Substring(pos + 1);

                        if (!_settings.ContainsKey(name))
                        {
                            _settings.Add(name, val);
                        }
                    }
                }
            }
        }
Пример #2
0
        public SettingsWriter(string appName, string fileName)
        {
            string path = Path.Combine(SettingsShared.GetMyAppDataDir(appName), fileName);

            _sw = new StreamWriter(path, false, Encoding.UTF8);
        }