1.準備html模板文件:Pages/Device/DeviceModel8.htmlhtml
2 using System.IO:讀取文件內容,並替換指定內容code
Div1.InnerHtml = "";
Stream myStream = new FileStream(HttpContext.Current.Server.MapPath(@"~/Pages/Device/DeviceModel8.html"), FileMode.Open);
Encoding encode = System.Text.Encoding.GetEncoding("GB2312");
StreamReader myStreamReader = new StreamReader(myStream, encode);
string strhtml = myStreamReader.ReadToEnd();
string stroutput = strhtml.Replace("$[Formitem0]$", "要替換的內容");
myStream.Seek(0, SeekOrigin.Begin);
myStream.SetLength(0);
StreamWriter sw = new StreamWriter(myStream, encode);
sw.Write(stroutput);
sw.Flush();
sw.Close();
myStream.Close();
Div1.InnerHtml = stroutput;orm
https://www.cnblogs.com/wangyt223/archive/2012/08/17/2643851.htmlhtm