会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
我的世界,我来创!
Create New World @@ $Adam$
博客园
首页
新随笔
联系
订阅
管理
获取站点路径方法
/**/
///
<summary>
///
保存程序失败及错误信息到日志
///
</summary>
///
<param name="opLog">
错误信息
</param>
public
void
SaveErrorLog(
string
message)
{
string
filePath
=
System.Web.HttpContext.Current.Server.MapPath(
"
~//LogFile//Test.txt
"
);
System.IO.StreamWriter srWriteLine
=
System.IO.File.CreateText(filePath);
srWriteLine.WriteLine(message);
srWriteLine.Close();
}
当前站点是:
http://localhost/App/Web
/**/
///
<summary>
///
保存程序失败及错误信息到日志
///
</summary>
///
<param name="opLog">
错误信息
</param>
public
void
SaveErrorLog(
string
message)
{
string
fileName
=
System.DateTime.Today.Year.ToString()
+
"
-
"
+
System.DateTime.Today.Month.ToString()
+
"
-
"
+
System.DateTime.Today.Day.ToString()
+
"
.txt
"
;
string
filePath
=
System.Web.HttpContext.Current.Server.MapPath(
"
~//LogFile//
"
+
fileName);
if
(
!
System.IO.File.Exists(filePath))
{
System.IO.StreamWriter srWriteLine
=
System.IO.File.CreateText(filePath);
srWriteLine.WriteLine(message);
srWriteLine.Close();
}
else
{
FileStream fsMyfile
=
new
FileStream(filePath,FileMode.Append, FileAccess.Write);
StreamWriter swMyfile
=
new
StreamWriter(fsMyfile);
swMyfile.WriteLine(message);
swMyfile.Flush();
swMyfile.Close();
fsMyfile.Close();
}
}
posted @
2007-03-08 16:33
Adam.Zhao
阅读(
382
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告