从记事本中提取特定的数据并显示在c#中的另一个记事本中
本文关键字:记事本 显示 另一个 数据 提取 | 更新日期: 2023-09-27 18:14:16
具体的数据我是指从一个关键字读取到另一个关键字从一个textFile和显示该数据在记事本上的toolStripMenuItem点击。
下面的代码只是显示文本文件的整个数据,但我想要特定的内容。
System.Diagnostics.Process.Start(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath) + "''someFile.txt");
我就这样试过了。
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");