复制代码 代码如下:
using System.Net;
using System.IO;
函数内容:
复制代码 代码如下:
///
/// 根据Url获得源文件内容
///
///合法的Url地址
///
public static string GetSourceTextByUrl(string url)
{
WebRequest request = WebRequest.Create(url);
request.Timeout = 20000;//20秒超时
WebResponse response = request.GetResponse();
Stream resStream = response.GetResponseStream();
StreamReader sr = new StreamReader(resStream);
return sr.ReadToEnd();
}
1.
2.
3.
4.
5.
6.
7.
8.