生成静态页面
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Web;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Web;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Program P = new Program();
{
class Program
{
static void Main(string[] args)
{
Program P = new Program();
OutPutHTML("http://localhost:4563/WebSite1/Default.aspx");
OutPutHTML("E:/WRoot/Tao/WebSite1/Default.aspx");
Console.Write("OK");
Console.ReadLine();
}
OutPutHTML("E:/WRoot/Tao/WebSite1/Default.aspx");
Console.Write("OK");
Console.ReadLine();
}
public static void OutPutHTML(string Url)
{
StreamWriter sw = null;
string errorMsg = "";
string str = "";
{
StreamWriter sw = null;
string errorMsg = "";
string str = "";
try
{
System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url);
// Get the response instance.
System.Net.WebResponse wResp = wReq.GetResponse();
// Read an HTTP-specific property
{
System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url);
// Get the response instance.
System.Net.WebResponse wResp = wReq.GetResponse();
// Read an HTTP-specific property
// Get the response stream.
System.IO.Stream respStream = wResp.GetResponseStream();
// Dim reader As StreamReader = New StreamReader(respStream)
System.IO.StreamReader reader = new System.IO.StreamReader(respStream , System.Text.Encoding.GetEncoding("gb2312"));
System.IO.Stream respStream = wResp.GetResponseStream();
// Dim reader As StreamReader = New StreamReader(respStream)
System.IO.StreamReader reader = new System.IO.StreamReader(respStream , System.Text.Encoding.GetEncoding("gb2312"));
try
{
Encoding Code = Encoding.GetEncoding("gb2312");
string path = "E:/WRoot/Tao/WebSite1/Default.html";
{
Encoding Code = Encoding.GetEncoding("gb2312");
string path = "E:/WRoot/Tao/WebSite1/Default.html";
str = reader.ReadToEnd();
sw = new StreamWriter(path , false , Code , 1024);
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
finally
{
sw.Close();
}
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
finally
{
sw.Close();
}
}
catch (System.Exception ex)
{
errorMsg = ex.Message;
}
}
}
}
catch (System.Exception ex)
{
errorMsg = ex.Message;
}
}
}
}