/// <summary>
/// 获取远程的字符串
/// </summary>
/// <param name="Url">url</param>
/// <returns>string</returns>
public string GetRemoteCode(String Url)
{
string strResult;
try
{
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(UrlEncode(Url));
myReq.Timeout = 10000;
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
Stream myStream = HttpWResp.GetResponseStream();
StreamReader sr = new StreamReader(myStream , Encoding.Default);
StringBuilder strBuilder = new StringBuilder();
while(-1 != sr.Peek())
{
strBuilder.Append(sr.ReadLine());
}
/// 获取远程的字符串
/// </summary>
/// <param name="Url">url</param>
/// <returns>string</returns>
public string GetRemoteCode(String Url)
{
string strResult;
try
{
HttpWebRequest myReq = (HttpWebRequest)HttpWebRequest.Create(UrlEncode(Url));
myReq.Timeout = 10000;
HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
Stream myStream = HttpWResp.GetResponseStream();
StreamReader sr = new StreamReader(myStream , Encoding.Default);
StringBuilder strBuilder = new StringBuilder();
while(-1 != sr.Peek())
{
strBuilder.Append(sr.ReadLine());
}
strResult = strBuilder.ToString();
}
catch(Exception exp)
{
strResult = "错误:" + exp.Message;
}
return strResult;
}