#region 计数器
if (!Page.IsPostBack)
{
string countFile = Server.MapPath("counter.txt");
int count = 1;
if (!File.Exists(countFile))
{
StreamWriter sw = File.CreateText(countFile);
sw.WriteLine("1");
sw.Flush();
sw.Close();
}
else
{
StreamReader srReadLine = new StreamReader(countFile, System.Text.Encoding.Default);
if (Session["VisitorNum"] == null)
{
count = Convert.ToInt32(srReadLine.ReadLine()) + 1;
srReadLine.Close();
try
{
StreamWriter sw = File.CreateText(countFile);
sw.WriteLine(count.ToString());
sw.Flush();
sw.Close();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
Session["VisitorNum"] = "wei";
}
else
{
count = Convert.ToInt32(srReadLine.ReadLine());
srReadLine.Close();
}
this.lblVistorNum.Text = count.ToString();
}
}
#endregion
本地计数器
最新推荐文章于 2022-10-23 23:15:25 发布
153

被折叠的 条评论
为什么被折叠?



