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();이어야합니다. –