public bool ReadConfigFile() { if (!File.Exists(_path)) return false; else if (_read) return false; else _read = true; try { StreamReader sr = new StreamReader(_path); string line = ""; POLConfigElem cur_elem = null; while ((line = sr.ReadLine()) != null) { //Remove any leading or trailing white space. line = line.Trim(new char[] { ' ', '\t' }); if (line.Length == 0) { if (cur_elem == null) _write_order.Add(new POLConfigLine(null, "")); else cur_elem.AddComment(""); continue; } if ( cur_elem == null ) { if (IsComment(line)) // Comment line outside an elem _write_order.Add(new POLConfigLine(null, line)); { int pos = 0; if ((pos = line.IndexOf('{')) > 0) { cur_elem = new POLConfigElem(line.Substring(0, pos)); } } } else { if (line[0] == '}') { _write_order.Add(cur_elem); cur_elem = null; } else if (IsComment(line)) cur_elem.AddComment(line); else { string name = ""; string value = ""; string comment = ""; if (SplitLine(line, out name, out value, out comment)) { cur_elem.AddProperty(name, value, comment); } } } } sr.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "POLConfig ReadConfigFile() Error"); return false; } return true; }