Example #1
0
        private void ReadFile()
        {
            configData.Clear();

            if (File.Exists(Path))
            {
                List <string> fileLines = new List <string>();

                using (var fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))
                    using (var sr = new StreamReader(fs))
                    {
                        while (!sr.EndOfStream)
                        {
                            fileLines.Add(sr.ReadLine());
                        }
                        sr.Close();
                    }

                foreach (string line in fileLines)
                {
                    configLine data = new configLine();
                    data.originalLine = line;

                    var parts = GetLineParts(line);
                    if (parts != null && parts.Length > 0)
                    {
                        data.key   = parts[0].ToLower();
                        data.value = parts.Length > 0 ? parts.Length == 1 ? parts[1] : string.Join(" ", parts.Skip(1)) : null;
                    }
                    configData.Add(data);
                }
            }
            else
            {
                InvokeNamecoinConfigInfo(string.Format("Creating default config file at {0}", Path));
            }
            Read = true;
        }
        private void ReadFile()
        {
            configData.Clear();

            if (File.Exists(Path))
            {
                List<string> fileLines = new List<string>();

                using (var fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Read, FileShare.Read))
                using (var sr = new StreamReader(fs))
                {
                    while (!sr.EndOfStream)
                        fileLines.Add(sr.ReadLine());
                    sr.Close();
                }

                foreach (string line in fileLines)
                {
                    configLine data = new configLine();
                    data.originalLine = line;

                    var parts = GetLineParts(line);
                    if (parts != null && parts.Length > 0)
                    {
                        data.key = parts[0].ToLower();
                        data.value = parts.Length > 0 ? parts.Length == 1 ? parts[1] : string.Join(" ", parts.Skip(1)) : null;
                    }
                    configData.Add(data);
                }
            }
            else
            {
                InvokeNamecoinConfigInfo(string.Format("Creating default config file at {0}", Path));
            }
            Read = true;
        }