欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

读取网页页面代码 并保存

程序员文章站 2022-06-13 10:09:21
...

//使用空间 using System.Net; using System.IO; if (!IsPostBack) { WebClient client = new WebClient(); string reply = client.DownloadString("http://www.sina.com"); TextArea1.Value = reply; } FileStream fs = new FileStream(@"c:/aa.html", File

//使用空间

using System.Net;

using System.IO;

if (!IsPostBack)

{

WebClient client = new WebClient();

string reply = client.DownloadString("http://www.sina.com");

TextArea1.Value = reply;

}

FileStream fs = new FileStream(@"c:/aa.html", FileMode.Create, FileAccess.Write);

StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.UTF8);

sw.Write(TextArea1.Value);

sw.Close();

fs.Close();