zoukankan
html css js c++ java
一个简单的日志类,测试时候用
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
}
查看全文
相关阅读:
windows2003 系统定时关机
利用批处理轻松压缩文件
JavaScript中的常用算法和函数
ASP.NET Session丢失问题原因及解决方案
JavaScript文字自动排版
js图片自动滚动并带翻页的功能
IE下不显示自定义错误页面
ArcObject 实现拓扑创建和检查
ArcGIS Server 的默认设置
ArcObject 要素删除
原文地址:https://www.cnblogs.com/gaomin/p/1294126.html
最新文章
回文判断
FOR ENGLISH
Cookie揭秘
块级元素和行内元素总结
JS的IE和FF兼容性问题汇总
Some English website & Preparation for interview in the future
关于JS的framework,我们了解多少?
HTML5 概述
在Asp.net中为图像加入版权信息
datagrid使用方法
热门文章
.NET下得到服务器主机名,IP和当前用户名
“...”替换超长字符
超详细的SQL语句语法
DataList嵌套
表现层绑定ID
轻松实现页面提交时,显示“提交中..”
英语日常用语集锦
查询从第二条到第七条记录方法
利用error替换无效图片
网页设计人员常用的N个小技巧
Copyright © 2011-2022 走看看