創建並編輯txt文件
public static void systemLog(string filename, string msg)
{
if (File.Exists (filename.Trim ()))
{
StreamWriter sw = File.AppendText(filename.Trim());
sw.WriteLine("\n");
sw.WriteLine(DateTime.Now.ToString() + msg);
sw.Close();
}
else
{
StreamWriter sw = File.CreateText(filename.Trim());
sw.WriteLine("\n");
sw.WriteLine(DateTime.Now.ToString() + msg);
sw.Close();
}
}