猿问

尝试读取 ResponseStream 时不支持指定的方法

我正在尝试将 responseStream 读取到最后,并在 br.ReadBytes 行中收到错误“不支持指定的方法”。


我究竟做错了什么?


WebResponse imageResponse = imageRequest.GetResponse();


Stream responseStream = imageResponse.GetResponseStream();


using (BinaryReader br = new BinaryReader(responseStream))

{

    imageBytes = br.ReadBytes((int)responseStream.Length);

    br.Close();

}


牛魔王的故事
浏览 187回答 1
1回答

ITMISS

我收到错误:NotSupportedException:此流不支持查找操作。假设您想要一个字节数组,为什么不让获取图像变得更容易:byte[] imageBytesusing (var webClient = new WebClient()) {    imageBytes = webClient.DownloadData("http://yourimage");}
随时随地看视频慕课网APP
我要回答