求助网站日访问量代码
//在新会话启动时运行的代码Application.Lock();
int count;//记录文本的日访问量
string nowday;//记录文本的访问日期
System.IO.StreamReader srd;
string strs;
string file_path = Server.MapPath("TextFile"); //取得文件的实际路径
srd = System.IO.File.OpenText(file_path);//打开文件进行读取
while (srd.Peek() != -1)
{
strs = srd.ReadLine();
}
srd.Close();
//将读取的信息存在字符数组str中
string str = strs.Split(',');
//日访问量
count = Convert.ToInt32(str[0]);
//最近一次访问时间
string day = str[1];
nowday = DateTime.Now.ToString();
//文件中保存的时间与系统时间相比,如果系统时间大,则重新开始计数
if (DateTime.Compare(Convert.ToDateTime(nowday), Convert.ToDateTime(day) >= 0))
{
count = 0;
day = DateTime.Now.AddDays(1).ToShortDateString() + "" + "00:00:00"; //day保存下一天的开始时间
string newdaystr ="0"+","+ day.ToString(); --------------------编程问答-------------------- 何必了?莫非是要练技术?那么多专业的统计直接用不久行了吗? --------------------编程问答-------------------- 记录到数据库得了. --------------------编程问答-------------------- http://www.cnzz.com/ --------------------编程问答-------------------- 站长统计 、 GG统计 都非常好,很详细。 --------------------编程问答-------------------- Application_Start中写 保存到一个全局变量(字典),把访问时间也保存到字典里,计算的时候 操作字典.
补充:.NET技术 , C#