下面的内容段是关于C#写入日志到文本文件的的内容。
using System.IO;
public static void ErrorLog(string mssg) {
string FilePath = HttpContext.Current.Server.MapPath("~/log/ErrorLog.txt");
try
{
if (File.Exists(FilePath))
{
using (StreamWriter tw = File.AppendText(FilePath))
{
tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
else
{
TextWriter tw = new StreamWriter(FilePath);
tw.WriteLine(DateTime.Now.ToString() + "> " + mssg);
tw.Flush();
tw.Close();
tw = null;
catch (Exception ex)