zoukankan      html  css  js  c++  java
  • 将网上的内容,读取到指定文件中【页面静态化】

    出错:

    已经将指定页面的内容读取到了test.html文件中,但是页面中有很多的乱码。

    以下是一个简单的,将aspx文件生成静态html文件的代码

    protected void Button1_Click(object sender, EventArgs e)
            {
                System.IO.StringWriter sw = new StringWriter();
                Server.Execute("index.aspx", sw);
                string contentStr = sw.ToString();
                string filePath = Server.MapPath("/");
                filePath += "test.html";
                StreamWriter stw = new StreamWriter(filePath, false, System.Text.Encoding.Default);
                stw.Write(contentStr);
                stw.Flush();
                stw.Close();
            }

     文件结构如下所示:

     

  • 相关阅读:
    Python 虚拟环境(VirtualEnv)
    python 枚举
    Python 面向对象编程
    Python 使用模块
    Python 函数
    Python dict & set
    JAVA-工具类
    09-12 练习题
    JAVA-数组
    java-语句
  • 原文地址:https://www.cnblogs.com/zyc19910109/p/9171898.html
Copyright © 2011-2022 走看看