2013-05-17 34 views
-2

具体数据我的意思是从一个关键字读取一个关键字到textFile中的另一个关键字并在toolStripMenuItem的记事本中显示该数据单击。从记事本中提取特定数据并在c中的另一个记事本中显示

以下代码仅用于显示文本文件的整个数据,但我只想要特定内容。

System.Diagnostics.Process.Start(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\someFile.txt"); 
+0

为什么-1我不明白,这个问题看起来不清楚吗? –

+0

从我的提示:使用减法方法。 – aef

回答

0

我只是试过这样。

如果(File.Exists(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)+ “\ comments_from_SSRD1.txt”)) File.Delete(Path.GetDirectoryName(System.Windows.Forms.Application。 ExecutablePath)+“\ file1.txt”);

 StreamWriter sw = null; 
     bool endFlag = false; 
     bool startFlag = false; 
     sw = File.AppendText(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\file1.txt"); 
     foreach (string lineOf in errorReportContent) 
     { 


      if (lineOf.Contains("Report Of Conditionals Mismatch")) 
      { 
       startFlag = true; 
      } 
      if (lineOf.Contains("End Of Conditionals Mismatch Report")) 
      { 
       endFlag = true; 
      } 
      if (startFlag == true && endFlag != true) 
      { 
       sw.WriteLine(lineOf); 
      } 





     } 
     sw.Close(); 
     System.Diagnostics.Process.Start(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\file1.txt");