文件名称:网站计数器
文件大小:927B
文件格式:CS
更新时间:2018-05-16 13:23:52
网站计数器
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; public partial class demo7_4 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { StreamReader readfile = File.OpenText(Server.MapPath("count.txt")); string str; int count; str = readfile.ReadLine(); count = int.Parse(str); count = count + 1; readfile.Close(); try { StreamWriter writefile = File.CreateText(Server.MapPath("count.txt")); writefile.WriteLine(count.ToString()); writefile.Close(); Response.Write("您是第"+count.ToString()+"位浏览者"); } catch (Exception) { Response.Write("文件写入失败,请检查!"); } } }