日期:2014-05-17 浏览次数:20410 次
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//完成下载以后更新下载次数
if (download())
{
int count = 0;
System.IO.StreamReader srd;
string file_path = Server.MapPath("~/count.txt");
srd = System.IO.File.OpenText(file_path);
while (srd.Peek() != -1)
{
string str = srd.ReadLine();
count = int.Parse(str);
}
srd.Close();
object obj = count;
Application["count"] = obj;
Application.Lock();
int State = 0;
State = (int)Application["count"];
State += 1;
obj = State;
Application["count"] = obj;
file_path = Server.MapPath("~/count.txt");
System.IO.StreamWriter srw = new System.IO.StreamWriter(file_path, false);
srw.WriteLine(State);
srw.Close();
Application.UnLock();
}
}
}