日期:2014-05-18 浏览次数:20914 次
public bool ExecAspxToHtml(string Url, string Path, string FileName) { try { StringWriter strHTML = new StringWriter(); System.Web.UI.Page myPage = new Page(); //System.Web.UI.Page中有个Server对象,我们要利用一下它 myPage.Server.Execute(Url, strHTML); //将asp_net.aspx将在客户段显示的html内容读到了strHTML中 StreamWriter sw = new StreamWriter(Path + FileName, true, System.Text.Encoding.GetEncoding("GB2312")); //新建一个文件Test.htm,文件格式为GB2312 sw.Write(strHTML.ToString()); //将strHTML中的字符写到Test.htm中 strHTML.Close(); //关闭StringWriter sw.Close(); //关闭StreamWriter return true; } catch { return false; } }