Global.asax文件:

using System.IO;
protected void Application_Start(object sender, EventArgs e)
{
FileStream fs = File.Open(Server.MapPath("counter.txt"),FileMode.OpenOrCreate);
StreamReader sr = new StreamReader(fs);
Application["count"] = Convert.ToInt32(sr.ReadLine());
sr.Close();
fs.Close();
}
//counter.txt会自动创建
protected void Session_Start(object sender, EventArgs e)
{
Application.Lock();
Application["count"] = (int)Application["count"] + ;
FileStream fs = File.Open(Server.MapPath("counter.txt"), FileMode.OpenOrCreate,FileAccess.ReadWrite);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine(Application["count"]);
sw.Close();
fs.Close();
Application.UnLock();
}

此种方法是把总人数记录在一个记事本文件中,使用文件流读写的方式来更新人数值,较为简单。

最新文章

  1. Single Number II
  2. ReactNative之style使用指南
  3. salt-master 的配置文件详解
  4. Eclipse编辑java文件报Unhandled event loop exception错误的解决办法
  5. [Oracle] Group By 语句的扩展 - Rollup、Cube和Grouping Sets
  6. 用java api读取HDFS文件
  7. ORACLE解锁数据库用户
  8. 使用telnet操作memcache,一般不常用
  9. jQuery插件实现select下拉框左右选择_交换内容(multiselect2side)
  10. HTML DOM nodeName nodeValue
  11. Python的下载和安装
  12. JavaScript 数组最大值
  13. 前端工程师:电信专业转前端是如何拿到阿里、腾讯offer的?
  14. 一键安装gitlab7在rehl6.4上
  15. python下的异常处理
  16. BZOJ.3252.攻略(贪心 长链剖分/线段树)
  17. JavaWeb基础-Jsp基础语法
  18. C# Task注意事项
  19. SimpleXML概述
  20. Nginx 限制php解析、限制浏览器访问

热门文章

  1. YY前端课程4
  2. Linux mount的使用
  3. Objective-C( Foundation框架 一 NSDictionary (NSMutaleDictionary))
  4. [IOS 开发] 懒加载 (延迟加载) 的基本方式,好处,代码示例
  5. Android 判断字符串是否为空
  6. Elasticsearch使用备忘
  7. whereis 和which
  8. javascript温故知新
  9. hdoj 5139Formula
  10. D. Game with Strings