C#

解决此流不支持查找操作[Exception type: NotSupportedException]

Posted by Leon on 2016-04-14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var myrequest = WebRequest.Create("http//www.example.com/xxxxx.jpg");
using (WebResponse response = myrequest.GetResponse())
{
using (Stream responseStream = response.GetResponseStream())
{
using (var stream = new MemoryStream())
{
const int bufferLength = 1024;
int actual;
byte[] buffer = new byte[bufferLength];
while ((actual = responseStream.Read(buffer, 0, bufferLength)) > 0)
{
stream.Write(buffer, 0, actual);
}
stream.Position = 0;
//逻辑处理
}
}
}