我只是试过这样。
如果(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");
为什么-1我不明白,这个问题看起来不清楚吗? –
从我的提示:使用减法方法。 – aef