日期:2014-05-20  浏览次数:20790 次

请问下这个怎么弄?
string   path   =   @ "..\..\ErrorMesage ";
if(!System.IO.Directory.Exists(path))
{
        System.IO.Directory.CreateDirectory(path);
        using(StreamWriter   sw   =   File.CreateText(path+@ "\errorMessage.txt "))
        {
                sw.WriteLine( "【 ");
                sw.WriteLine( "错误时间: "+dt);
                sw.WriteLine( "错误信息: "+errorMessage);
                sw.WriteLine( "错误位置: "+StackTrace);
                sw.WriteLine( "】 ");
                sw.WriteLine( "\r\n ");
        }
}
else
{
        using(StreamWriter   sw   =   File.CreateText(path+@ "\errorMessage.txt "))
        {
                sw.WriteLine( "【 ");
                sw.WriteLine( "错误发生时间: "+dt);
                sw.WriteLine( "错误信息: "+errorMessage);
                sw.WriteLine( "错误发生位置: "+StackTrace);
                sw.WriteLine( "】 ");
                sw.WriteLine( "\n ");
          }
}

这个怎么加进代码里?

------解决方案--------------------
不明白lz要干什么?
------解决方案--------------------
UP
------解决方案--------------------
樓主好像是在進行錯誤處理,應該放在try catch 裡面把?
------解决方案--------------------
不是很清楚lz要干什么,ms这个是出错后的处理,应该放在 catch里面

代码冗余大了点儿
------解决方案--------------------
说来话长啊.
当年冯若依曼...