これは非常に簡単な修正であるはずですが、何らかの理由で何かが足りません。私がやろうとしているのは、ヘッダーを書かなければならない文字列ビルダー関数を取得することだけですが、何らかの理由で現在はそうではありません。
ifステートメントを!File.Exists(tempFileName)に変更しようとすると、ループが実行されません。
助言がありますか?また、さらに情報が必要な場合はお知らせください。前もって感謝します。
public static void Open(string tempFileName, string division,
int zipFiles, int conversions, int returnedFiles, int totalEmails)
{
StreamWriter dailyStats;
//This is where I am missing something
//I am passing in the original filename of a log, then adding "-Stats.log"
//so I can tell the difference between what is the new stats file, and the original log file
if (File.Exists(tempFileName))
{
dailyStats = new StreamWriter(tempFileName + "-Stats.log");
StringBuilder sb = new StringBuilder();
sb.Append("Division");
sb.Append("\t");
sb.Append("Zip Files");
sb.Append("\t");
sb.Append("Conversions");
sb.Append("\t");
sb.Append("Returned Files");
sb.Append("\t");
sb.Append("Total E-Mails");
sb.Append("\t");
}
else
{
dailyStats = File.AppendText(tempFileName + "-Stats.log");
}
if (writeLog)
{
//Use a string builder to assemble the content for performance reasons
StringBuilder s = new StringBuilder();
s.Append(division);
s.Append("\t");
s.Append(zipFiles);
s.Append("\t");
s.Append(conversions);
s.Append("\t");
s.Append(returnedFiles);
s.Append("\t");
s.Append(totalEmails);
s.Append("\t");
dailyStats.WriteLine(s.ToString());
}
dailyStats.Close();
}