創建並編輯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();
       
            }
        }
posted @ 2007-04-02 09:05  Nina  阅读(576)  评论(0编辑  收藏  举报