Пример #1
0
        public SettingsReader(string appName, string fileName, string appPath)
        {
            _settings   = new Dictionary <string, string>();
            profilePath = SettingsShared.GetProfileDir(appName, appPath);
            string path = Path.Combine(profilePath, fileName);

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

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

                while ((line = sr.ReadLine()) != null)
                {
                    pos = line.IndexOf('=');
                    if (pos != -1)
                    {
                        if (pos > 0)
                        {
                            name = line.Substring(0, pos);
                            val  = line.Substring(pos + 1);
                            if (!_settings.ContainsKey(name))
                            {
                                _settings.Add(name, val);
                            }
                        }
                        else
                        {
                            val = line.Substring(pos + 1);
                            if (_settings.ContainsKey(name))
                            {
                                _settings[name] += "\r\n" + val;
                            }
                        }
                    }
                }
            }
        }
Пример #2
0
        public SettingsWriter(string appName, string fileName, string appPath)
        {
            string path = Path.Combine(SettingsShared.GetProfileDir(appName, appPath), fileName);

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