小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

網(wǎng)頁靜態(tài)化,生成靜態(tài)文件的類

 jsjjtylz 2014-01-11
網(wǎng)頁靜態(tài)化,生成靜態(tài)文件的類

using System;
using System.IO;
using System.Net;
using System.Web;
namespace ClassLibrary.DataClass
{
/// <summary>
/// GenHtml 的摘要說明。
/// </summary>
public class GenHtml
{
     public static    string path="";
     public static    string fileName="";
     public static    string transUrl="";

    public GenHtml()
    {
     //
     // TODO: 在此處添加構(gòu)造函數(shù)邏輯
     //
    }

    /// <summary>
    /// 轉(zhuǎn)換成靜態(tài)文件
    /// </summary>
    /// <param name="path">要寫入靜態(tài)文件的真實(shí)路徑</param>
    /// <param name="fileName">真實(shí)的文件名</param>
    /// <param name="transUrl">要轉(zhuǎn)換的地址</param>
    public static bool writeFile(string path, string fileName, string transUrl)
    {

     //是否正確生成
     bool bSuccess = false;
     StreamReader sr;
     StreamWriter sw;
     try 
     {
      WebRequest HttpWebRequest = WebRequest.Create(transUrl);
      WebResponse HttpWebResponse = HttpWebRequest.GetResponse();
      sr = new StreamReader(HttpWebResponse.GetResponseStream());
      string strHtml = sr.ReadToEnd();
      sr.Close();     
      if(!System.IO.Directory.Exists(path))
      {
    
      System.IO.Directory.CreateDirectory(path);
      }
      string PathAndName = path + fileName;
      if (System.IO.File.Exists(PathAndName))
      {
       System.IO.File.Delete(PathAndName);
      }
      sw = File.CreateText(PathAndName);
      sw.WriteLine(strHtml);
      sw.Close();
      //生成成功
      bSuccess = true;
     }
     catch
     {
       
     
     }
        
     return bSuccess;
   
        
    }



    public void    threadWriteFile()
    {
  
  
     StreamReader sr;
     StreamWriter sw;
     try 
     {
      WebRequest HttpWebRequest = WebRequest.Create(transUrl);
      WebResponse HttpWebResponse = HttpWebRequest.GetResponse();
      sr = new StreamReader(HttpWebResponse.GetResponseStream());
      string strHtml = sr.ReadToEnd();
      sr.Close();     
      if(!System.IO.Directory.Exists(path))
      {
    
       System.IO.Directory.CreateDirectory(path);
      }
      string PathAndName = path + fileName;
      if (System.IO.File.Exists(PathAndName))
      {
       System.IO.File.Delete(PathAndName);
      }
      sw = File.CreateText(PathAndName);
      sw.WriteLine(strHtml);
      sw.Close();
   
     }
     catch
     {
       
     
     }
        
   
  
    }

    /// <summary>
    /// 刪除生成文件
    /// </summary>
    /// <param name="path">文件真實(shí)路徑</param>
    /// <param name="fileName">文件名</param>
    /// <returns>布爾值</returns>
    public static bool delFile(string path,string fileName)
    {
  
     //是否成功的標(biāo)志
     bool bSuccess=false;
     try
     {
      string pathAndName=path+fileName;
   
      if(System.IO.File.Exists(pathAndName))
      {
    
       System.IO.File.Delete(pathAndName);
    
       bSuccess=true;
    
      }
   
   
     }
     catch
     {
   
   
     }
  
  
    return bSuccess;
  
  
    }



}
}

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多