My Solution:
using (StreamReader sr = new StreamReader(filename))
{
Rules.Rows.Clear();
string line;
while ((line = sr.ReadLine()) != null)
{
if (line.Contains("Bool"))
{
string[] line1 = Regex.Split(line, ",");
if (line1[1] == "And")
{
RbAnd.Checked = true;
RbOr.Checked = false;
}
else
{
RbAnd.Checked = false;
RbOr.Checked = true;
}
}
if (line.Contains(",") && !line.Contains("Bool"))
{
string[] line2 = Regex.Split(line, ",");
string val1 = line2[0];
string val2 = line2[1];
string val3 = string.Empty;
if (!string.IsNullOrEmpty(line2[2]) && line2.Length.Equals(3))
{
val3 = line2[2];
}
Rules.Rows.Add(val1, val2, val3);
}
}
sr.Close();
}