特定数据我的意思是从textFile读取一个关键字到另一个关键字,并在toolStripMenuItem上的记事本中显示该数据。点击。
以下代码仅用于显示文本文件的整个数据,但我只想要特定内容。
System.Diagnostics.Process.Start(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "\\someFile.txt");
答案 0 :(得分:0)
我只是这样试过。
if(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");