日期:2014-05-16 浏览次数:21059 次
/// <summary>
/// 请求路径返回源代码
/// </summary>
/// <param name="sUrl">请求地址</param>
/// <param name="sCoding">编码格式</param>
/// <param name="sMsg"></param>
/// <returns></returns>
public bool RequestUrlToString(string sUrl, string sCoding, ref string sMsg)
{
try
{
HttpWebRequest request = CreateWebRequest(sUrl);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();//获得回应的数据流
//将数据流转成 String
sMsg = new StreamReader(stream, System.Text.Encoding.GetEncoding(sCoding)).ReadToEnd();
return true;
}
catch (Exception ex)
{
sMsg = "" + ex.Message;
return false;
}
}
/// <summary>
/// 请求图片路径保存图片
/// </summary>
/// <param name="sImageUrl">图片路径</param>
/// <param name="sFullFileName">保存图片的完整路径</param>
/// <param name="sMsg"></param>
&n