会员
周边
众包
新闻
博问
闪存
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
gaomin
博客园
首页
新随笔
联系
订阅
管理
一个简单的日志类,测试时候用
Code
1
class
LogWriter
2
{
3
private
static
string
path
=
Application.StartupPath
+
"
\\log.txt
"
;
4
static
LogWriter()
5
{
6
7
if
(
!
File.Exists(path))
8
{
9
FileStream fs
=
File.Create(path);
10
fs.Close();
11
}
12
13
Log(
"
Log Start:
"
);
14
}
15
16
public
static
void
Log(
string
str)
17
{
18
StreamWriter sw
=
File.AppendText(path);
19
sw.WriteLine(DateTime.Now.ToLongTimeString()
+
"
:
"
+
str);
20
sw.Close();
21
}
22
23
public
static
void
Error(
string
str)
24
{
25
StreamWriter sw
=
File.AppendText(path);
26
sw.WriteLine(DateTime.Now.ToLongTimeString()
+
"
: Error
"
+
str);
27
sw.Close();
28
}
29
}
posted @
2007-08-31 02:50
Jim Gao
阅读(
127
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部
公告