訪客圖形計數器

訪客圖形計數器

 

01 StreamReader sr = new StreamReader(Server.MapPath("Counter.txt"));
02 string visitors = sr.ReadLine();
03 visitors = (Convert.ToInt64(visitors) + 1).ToString();
04
05 int Length = 0;
06 string strURL = "";
07
08 while (Length < visitors.Length)
09 {
10     strURL += "<img src='num/" + visitors.Substring(Length, 1) + ".gif'>";
11     Length++;
12 }

13
14 sr.Close();
15 sr.Dispose();
16
17 StreamWriter sw = new StreamWriter(Server.MapPath("Counter.txt"));
18 sw.WriteLine(visitors);
19
20 sw.Close();
21 sw.Dispose();
22
23 this.Label1.Text = strURL;