BitServer.INI.getSettings C# (CSharp) Method

getSettings() public static method

public static getSettings ( string Filename, string Section ) : NameValueCollection
Filename string
Section string
return System.Collections.Specialized.NameValueCollection
        public static NameValueCollection getSettings(string Filename, string Section)
        {
            bool inSec = false;
            NameValueCollection nc = new NameValueCollection();
            if (File.Exists(Filename))
            {
                string[] Lines = File.ReadAllLines(Filename);
                foreach (string line in Lines)
                {
                    if (line.Length > 0 && !line.StartsWith(";"))
                    {
                        if (line.StartsWith("[") && line.EndsWith("]"))
                        {
                            inSec = (line.Substring(1, line.Length - 2) == Section);
                        }
                        else if (inSec && line.Contains("="))
                        {
                            nc.Add(line.Split('=')[0].Trim(), line.Split(new char[] { '=' }, 2)[1]);
                        }
                    }
                }
                return nc;
            }
            return null;
        }