BF2Statistics.ServerSettings.ServerSettings C# (CSharp) Method

ServerSettings() public method

Constructor
public ServerSettings ( string FileName ) : System
FileName string The full path to the settings.con file
return System
        public ServerSettings(string FileName)
        {
            // Load the settings file
            SettingsFile = new FileInfo(FileName);
            if(!SettingsFile.Exists)
                throw new Exception("Server settings file does not exist!");

            string contents;

            // Try to open the settings file with READ/WRITE access
            try
            {
                using (Stream Str = SettingsFile.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
                using (StreamReader Rdr = new StreamReader(Str))
                    contents = Rdr.ReadToEnd();
            }
            catch (Exception e)
            {
                throw new Exception("Unable to Read/Write to the settings file: " + e.Message, e);
            }

            // Get all Setting Matches
            Regex Reg = new Regex(@"sv.(?:set)?(?<name>[A-Za-z]+)[\s|\t]+([""]*)(?<value>.*)(?:\1)");
            MatchCollection Matches = Reg.Matches(contents);

            // Add each found match to the Items Dictionary
            foreach (Match m in Matches)
                Items.Add(m.Groups["name"].Value, m.Groups["value"].Value);
        }