<%@ Page Language="C#" %> <% //Första blocket är identiskt med uppgift 1.1.1 int count = 0; lock (this) { const String path = "/export/Webbserver/ip/ip2/3.1/counter.txt"; if (System.IO.File.Exists(path)) { System.IO.StreamReader inFile = new System.IO.StreamReader(path); count = Int32.Parse(inFile.ReadLine()); inFile.Close(); } count++; System.IO.StreamWriter outFile = new System.IO.StreamWriter(path); outFile.WriteLine("" + count); outFile.Close(); } //Öppna mallfilen System.IO.StreamReader htmlFile = new System.IO.StreamReader("/export/Webbserver/ip/ip2/3.1/output.htm"); while (true) { //Läs in rad för rad, men byt ut det magiska ordet mot resultatet innan det skrivs ut String line = htmlFile.ReadLine(); if (line == null) { break; } Response.Write(line.Replace("&COUNT", count.ToString()) + Environment.NewLine); } htmlFile.Close(); %>