private void menu_check(object sender, RoutedEventArgs e) { string tmp = (sender as MenuItem).Tag.ToString(); if (tmp.Equals("open")) { Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog(); openFileDialog.Title = "Select File"; openFileDialog.Filter = "Log文件|*.Log|所有文件|*.*"; openFileDialog.FileName = string.Empty; openFileDialog.FilterIndex = 1; openFileDialog.RestoreDirectory = true; if ((bool)openFileDialog.ShowDialog().GetValueOrDefault()) { _LogLineTxt.Clear(); Fun_Show_txt.Items.Clear(); using (StreamReader streamReader = File.OpenText(openFileDialog.FileName)) { //Paragraph paragraph = new Paragraph(); //paragraph.Inlines.Add(streamReader.ReadToEnd()); LogLineTxt tmptxt; while (!streamReader.EndOfStream) { string linetxt = streamReader.ReadLine(); tmptxt = new LogLineTxt(linetxt); _LogLineTxt.Add(tmptxt); Fun_Show_txt.Items.Add(linetxt); } } } } }