• C#:读取html模板文件,并替换修改文件中指定值,保存为修改后的文件


    1.准备html模板文件:Pages/Device/DeviceModel8.html

    2 using System.IO:读取文件内容,并替换指定内容

                            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;

    https://www.cnblogs.com/wangyt223/archive/2012/08/17/2643851.html

  • 相关阅读:
    Jsp入门EL表达式_学习笔记
    sql-DDL, DML 常用语句
    sql-DDL, DML 常用语句
    sql-DDL, DML 常用语句
    sql-DDL, DML 常用语句
    谁需要GUI?快看Linux 终端生存之道
    谁需要GUI?快看Linux 终端生存之道
    谁需要GUI?快看Linux 终端生存之道
    谁需要GUI?快看Linux 终端生存之道
    2.3 根据层级查找元素
  • 原文地址:https://www.cnblogs.com/July-/p/9627394.html
Copyright © 2020-2023  润新知