private void Window_Loaded(object sender, RoutedEventArgs e) { try { StreamReader sr = new StreamReader("rule.dat"); int ruleCount = int.Parse(sr.ReadLine()); for (int i = 0; i < ruleCount; i++) { Rule rule = new Rule(); rule.readRule(sr); dataGrid.Items.Add(rule); } sr.Close(); } catch { } }
public void loadRule() { ruleList.Clear(); try { StreamReader sr = new StreamReader("rule.dat"); int ruleCount = int.Parse(sr.ReadLine()); for (int i = 0; i < ruleCount; i++) { Rule rule = new Rule(); rule.readRule(sr); ruleList.Add(rule); } sr.Close(); } catch { } }