我在我的 logtext.txt 文件中保存日志消息。我想在这个文件中给日志消息编号,有什么解决方案可以解决这个问题吗?下面是我的代码:
// Create a writer and open the file:
StreamWriter log;
if (!File.Exists(AssetXMLLogMessagesPath + ".txt"))
{
log = new StreamWriter( AssetXMLLogMessagesPath + ".txt", true);
}
else
{
log = File.AppendText(AssetXMLLogMessagesPath + ".txt");
}
// Write to the file:
log.WriteLine(" "+"<------------------------------"+" AssetImporter at "+":" +" "+ DateTime.Now.ToString("F") + "--------------------------------------->");
log.WriteLine(msg);
log.WriteLine();
// Close the stream:
log.Close();