0
我有這個ASP頁面和每個請求我想添加計數值1,並顯示值,並保持計數值在文本流這裏是我的代碼,但問題是沒有什麼加載頁面ASP頁面請求數
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
System.IO.StreamWriter sw;
System.IO.StreamReader sr ;
int count=0;
if (!System.IO.File.Exists(@"filepath\ResponsCount.txt"))
{
sw = new System.IO.StreamWriter(@"filepath\ResponsCount.txt");
sw.WriteLine("count.ToString()");
}
else
{
sr = new System.IO.StreamReader(@"filepath\ResponsCount.txt");
count = int.Parse(sr.ReadLine());
count++;
sw = new System.IO.StreamWriter(@"filepath\ResponsCount.txt");
sw.WriteLine(count.ToString());
}
Label2.Text = count.ToString();
}
</script>
你好像不關閉流寫入器....應該是sw.Close(); –