写入临时日志到文本

写入临时日志到文本
       private void ToOrderExceptionLog(string strMsg)
        {
            String saveUri ="D:\\调试日志";
            if (Directory.Exists(saveUri))
            {
                String saveFileName = @saveUri + "\\" + DateTime.Now.ToLongDateString() + ".txt ";
                FileInfo nfile = new FileInfo(saveFileName);
                if (!nfile.Exists) { FileStream crtorchage = System.IO.File.Create(saveFileName); crtorchage.Flush(); crtorchage.Close(); }
                StreamWriter wt = new StreamWriter(saveFileName, true);//以可以追加文本的方式打开nfile流  
                wt.WriteLine(strMsg); wt.Flush(); wt.Close();
            }
            else
            {
                Directory.CreateDirectory(saveUri);
                String saveFileName = @saveUri + "\\" + DateTime.Now.ToLongDateString() + ".txt ";
                FileStream crtorchage = System.IO.File.Create(saveFileName);
                crtorchage.Flush(); crtorchage.Close();
                StreamWriter wt = new StreamWriter(saveFileName);//不可追加文本  
                wt.WriteLine(strMsg); wt.Flush(); wt.Close();
            }
        }
写入临时日志到文本

写入临时日志到文本

上一篇:C#基础|值类型和引用类型以及传参问题


下一篇:浅析MySQL_5.0的my.cnf文件