runxinzhi.com
首页
百度搜索
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)中最好.
相关阅读:
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记九:导航结构层次
windows live messenger 2009登录失败,提示“错误代码:81000605”的一个解决办法
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记七:执行聚合(上)
Java反编译插件Jdclipse导致Eclipse 3.7.2启动崩溃的解决方法
关于婚姻,你能事先回答这些问题吗?(来自网络)
邀月的一些其他随笔索引
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记十一:计算成员和动态命名集
一点一滴培养你的领袖气质,要经常自我激励(转自网络)
Firefox中卸载Java Console
Jquery.Validate验证CheckBoxList,RadioButtonList,DropDownList是否选中
原文地址:https://www.cnblogs.com/oisiv/p/407256.html
最新文章
二维码原理简介
编译android遇到java虚拟机堆内存不够的问题
android snod 编译到system.img中
android Gsensor调成四个方向
Android JNI, .so library 调试命令
git revert 和 git reset的区别
git checkout b test1 index
cocos2dx for android:ubuntu 环境搭建
Intent.ACTION_MEDIA_SCANNER_SCAN_FILE:扫描指定文件
Anroid 异常:is not valid; is your activity running?
热门文章
给android添加系统属性:Settings.system和SystemProperties
android4.0.3 phone 和 tablet 模式设置 修改点
android上传图片至服务器
如何调用Android隐藏API
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记八:执行聚合(下)
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记十二:动态安全
Proclarity的替代产品
安装SQL Server 2008反复提示需要安装MICROSOFT .NET FRAMEWORK 3.5 SP1的一个解决办法
《Microsoft SQL Server 2008 MDX Step by Step》学习笔记十:Time进阶
Windows Install Clean Up-windows安装卸载终极利刃
Copyright © 2020-2023
润新知