会员
周边
众包
新闻
博问
闪存
赞助商
所有博客
当前博客
我的博客
我的园子
账号设置
简洁模式
...
退出登录
注册
登录
一个人-我的学习随笔
有时候对待技术就好像对待女人,我们通常在已经了解或者相信她有着诱人的身体的时候,才会乐于或者有耐心对待脱衣的前戏。
博客园
::
首页
::
博问
::
闪存
::
新随笔
::
联系
::
订阅
::
管理
::
公告
c#中幾個常用代碼
文件操作
string
path
=
@"
e:\MyTest.txt
"
;
DateTime dt
=
DateTime.Now;
if
(
!
File.Exists(path))
{
//
Create a file to write to.
using
(StreamWriter sw
=
File.CreateText(path))
{
sw.WriteLine(
"
time
"
+
dt.ToString());
sw.WriteLine(hashtable.Count.ToString());
}
}
else
{
using
(StreamWriter sw
=
File.AppendText(path))
{
sw.WriteLine(
"
time
"
+
dt.ToString());
sw.WriteLine(hashtable.Count.ToString());
}
}
web應用中的Cache操作
Cache cache
=
System.Web.HttpContext.Current.Cache;
string
obj
=
null
;
cache.Insert(
"
cache1
"
,obj,
null
,DateTime.Now.AddHours(
1
),TimeSpan.Zero,CacheItemPriority.AboveNormal,
null
);
當然對於簡單的字符串,使用以下方式即可
Application[
"
Title
"
]
=
"
Test Sample
"
;
cache操作可以放在任何地方,當然放在Global.asax的Application_Start(Object sender, EventArgs e)中最好.
posted on
2006-05-23 16:32
oisiv
阅读(
261
) 评论(
0
)
编辑
收藏
举报
会员力量,点亮园子希望
刷新页面
返回顶部