zoukankan      html  css  js  c++  java
  • 自动生成 html5 小页面


                StringBuilder htmltext = new StringBuilder();
                try
                {
                    //var readPath = Server.MapPath("~/Template/test.html"+templatePage);
                    var readPath = Server.MapPath("~/Template/" + scModel.TemplateName);
                    using (StreamReader sr = new StreamReader(readPath)) //模板页路径
                    {
                        String line;
                        while ((line = sr.ReadLine()) != null)
                        {
                            htmltext.Append(line);
                        }
                        sr.Close();
                    }
                }
                catch
                {
                    Response.Write("<Script>alert('读取文件错误')</Script>");
                }
                #region  字符串替换
                //第一页
                htmltext.Replace("#MsProducts#", scModel.MsProducts);
                htmltext.Replace("#Industry#", scModel.Industry);
                #endregion
                try
                {
                    // var newPath = Server.MapPath("~/solution/test.html");
                    var newPath = Server.MapPath("~/solution/" + scModel.PageName);
                    using (StreamWriter sw = new StreamWriter(newPath, false, System.Text.Encoding.GetEncoding("UTF-8"))) //保存地址
                    {
                        sw.WriteLine(htmltext);
                        sw.Flush();
                        sw.Close();
                    }
                }
                catch
                {
                    Response.Write("<Script>alert('读取文件错误')</Script>");
                }

  • 相关阅读:
    使用javaDate类代数据仓库维度表
    Hermes和开源Solr、ElasticSearch 不同
    MapReduce 异常 LongWritable cannot be cast to Text
    吐槽CSDN编辑
    Codeforces 452A Eevee
    看不清楚未来,请做好如今
    JDBC数据库连接
    mixpanel实验教程(2)
    使用jquery+一般处理程序异步载入信息
    Eclipse中的Maven项目报Unbound classpath variable错误
  • 原文地址:https://www.cnblogs.com/hanxingli/p/5486862.html
Copyright © 2011-2022 走看看