zoukankan      html  css  js  c++  java
  • 从Discuz!NT v2.0扣出来的生成静态页面的方法

    asp.net下生成静态页的方法有很多,目前我尝试过的方法4-5种,前几天在看Discuz!NT v2.0的源码时,发现了下面的代码。原理很简单,不啰唆了,直接看代码好了:
            /// <summary>
            
    /// 转换为静态html
            
    /// </summary>

            public void transHtml(string path,string outpath)        
            
    {
                Page page 
    = new Page();
                StringWriter writer 
    = new StringWriter();
                page.Server.Execute(path, writer);
                FileStream fs;
                
    if(File.Exists(page.Server.MapPath(""+ """ + outpath))              
                
    {
                    File.Delete(page.Server.MapPath(
    ""+ """ + outpath);
                    fs 
    = File.Create(page.Server.MapPath(""+ """ + outpath);
                }

                
    else            
                
    {
                    fs 
    = File.Create(page.Server.MapPath(""+ """ + outpath);
                }

                
    byte[] bt = Encoding.Default.GetBytes(writer.ToString());
                fs.Write(bt,
    0,bt.Length);
                fs.Close();
            }
  • 相关阅读:
    Day11作业
    day12作业
    samba共享服务
    PHP7 redis扩展安装
    linux lin命令
    PhpStorm,Pycharm,Goland破解
    PHP规范PSR2
    PHP 过滤器(Filter)
    Linux下Redis的安装与配置
    linux命令汇总
  • 原文地址:https://www.cnblogs.com/leeolevis/p/1383188.html
Copyright © 2011-2022 走看看