一个人-我的学习随笔

有时候对待技术就好像对待女人,我们通常在已经了解或者相信她有着诱人的身体的时候,才会乐于或者有耐心对待脱衣的前戏。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

文件操作

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编辑  收藏  举报