private void ReadDefineText() { string path; string define; string Name; int ClrValue; string ToParse; ; OpenFileDialog openFile = new OpenFileDialog { Title = "Open text file of #define lines", InitialDirectory = "D:\\OneDrive\\Documents\\vFE_Files\\Resources\\", Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*", RestoreDirectory = true, }; if (openFile.ShowDialog() == DialogResult.OK) { path = openFile.FileName; string[] Lines = File.ReadAllLines(path); foreach (string Line in Lines) { ToParse = Line; define = ToParse.Substring(0, ToParse.IndexOf(" ")).Trim(); if (define.IndexOf("#define") != -1) { ToParse = ToParse.Substring(ToParse.IndexOf(" ") + 1); Name = ToParse.Substring(0, ToParse.IndexOf(" ")).Trim(); ToParse = ToParse.Substring(ToParse.IndexOf(" ") + 1); ClrValue = Convert.ToInt32(ToParse); Clr.Rows.Add(Name, ClrValue); } } Debug.WriteLine("Table has " + Clr.Rows.Count); } }