Stream writer = request.GetRequestStream()
GetRequestStream()总提示System.NotSupportedException 类型的异常
WebResponse response = webrequest.GetResponse();
Stream s = response.GetResponseStream();
GetResponseStream()总提示System.NotSupportedException 类型的异常
public static byte[] Get(string url, Action<int> onPercentChange = null) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Timeout = kRequestTimeout; request.Method = "GET"; request.Referer = url; request.CookieContainer = _cookie; return Download(request, onPercentChange); } private static byte[] Download(HttpWebRequest request, Action<int> onPercentChange) { HttpWebResponse response = (HttpWebResponse)request.GetResponse(); long length = response.ContentLength; int bytePerTime = (int)(length / 100 + 1); byte[] receiveBytes = new byte[bytePerTime * 100]; BinaryReader br = new BinaryReader(response.GetResponseStream()); for (int k = 0; k < 100; k++) { byte[] buffer = br.ReadBytes(bytePerTime); Array.Copy(buffer, 0, receiveBytes, bytePerTime * k, buffer.Length); if (onPercentChange != null) onPercentChange(k); } br.Close(); response.Close(); return receiveBytes; }