.net中统计访问次数出现问题
string s = "\\controls\\log.txt"; void Application_Start(object sender, EventArgs e) { // 在应用程序启动时运行的代码 FileStream fs = new FileStream(Server.MapPath(".") + s, FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs, Encoding.Default); StringBuilder sb = new StringBuilder(); string temp = ""; while ((temp = sr.ReadLine()) != null) sb.Append(temp); string result = sb.ToString().Trim (); int count = Convert.ToInt32(result); Application["count_web"] =count; Application ["num"] = 1; } void Application_End(object sender, EventArgs e) { // 在应用程序关闭时运行的代码 System.IO.File.Delete(Server.MapPath(".") + s); System.IO.File.Create(Server.MapPath(".") + s); StreamWriter sw = new StreamWriter(Server.MapPath(".") + s); sw.Write(Application["count_web"].ToString()); sw.Flush(); } void Application_Error(object sender, EventArgs e) { // 在出现未处理的错误时运行的代码 } void Session_Start(object sender, EventArgs e) { // 在新会话启动时运行的代码 Application.Lock(); Application["count_web"] =Convert .ToInt32 ( Application["count_web"])+1; Application ["num"] = Convert .ToInt32 ( Application ["num"])+1; Application.UnLock(); } void Session_End(object sender, EventArgs e) { // 在会话结束时运行的代码。 // 注意: 只有在 nfig 文件中的 sessionstate 模式设置为 // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer // 或 SQLServer,则不会引发该事件。 Application.Lock(); Application ["num"] = Convert.ToInt32(Application ["num"]) - 1; Application.UnLock(); } 我建了一个log.txt的文件,用来保存总访问次数。 如上,已经实现了从log.txt中读取总访问次数,但是却无法实现往log.txt中写入总访问次数。 请问这是什么原因了。
提示什么,是不是没有写权限。为什么不用数据库。如果多人同时访问,对log.txt的打开和写入是不是会有冲突呢。
答:点击某个button时,调用show(i),把id为"div"+i的那一层的display设为block(简单点说就是,如果你点了第一个button,就显示id...详情>>
答:在 VS 2008中,我们就开发人员所关心的一些常见的使用场景在性能上作了很大的改进.我们对新的产品功能以及现有的产品功能都设置了明确的性能指标。 例如,对于新...详情>>