天天看點

簡單C#生成靜态及相關讀取模闆檔案

簡單C#生成靜态及相關讀取模闆檔案
簡單C#生成靜态及相關讀取模闆檔案

代碼

        string gh = HttpRuntime.AppDomainAppPath;

        StreamReader reader = new StreamReader(gh+"/33.htm", Encoding.GetEncoding("gb2312"));

        string html = reader.ReadToEnd();

        html = html.Replace("<!--123-->", "好好");

        Response.Write(html);

        StreamWriter sw = new StreamWriter(Server.MapPath("311.htm"), false, System.Text.Encoding.GetEncoding("GB2312"));

        sw.WriteLine(html);

        sw.Flush();

        sw.Close();