当我尝试解压缩“test.png”时,我收到以下错误:此流不支持搜索操作。
还可以使用通配符吗? var entry = zipout [“*。png”];流媒体时我不会知道同样的事情。
var request = (HttpWebRequest)WebRequest.Create("http://www.xxx.xxxx.com/xxx/xxxx?key=ndXqH2fXzePomlVoX39trxUf%2FV1bfN0rZsHsTyEvI%2F0%3D&labelFormat=png");
using (var ms = new MemoryStream())
{
using (var response = (HttpWebResponse)request.GetResponse())
{
using (var stream =response.GetResponseStream())
{
using (var zipout = ZipFile.Read(stream))
{
var entry = zipout["test.png"];
entry.Extract(ms);
}
}
}
}
更新了
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (var stream = new MemoryStream())
{
if (responseStream != null)
{
responseStream.CopyTo(stream);
}
using (var zipout = ZipFile.Read(stream))
{
using (var ms = new MemoryStream())
{
var entry = zipout["test.png"];
entry.Extract(ms);
}
}
}
}
}
新错误:Message =“无法将其读作ZipFile”
答案 0 :(得分:0)
var request = (HttpWebRequest)WebRequest.Create("var request = (HttpWebRequest)WebRequest.Create("http://www.xxx.xxxx.com/xxx/xxxx?key=ndXqH2fXzePomlVoX39trxUf%2FV1bfN0rZsHsTyEvI%2F0%3D&labelFormat=png");
using (var response = request.GetResponse())
{
using (var responseStream = response.GetResponseStream())
{
using (var stream = new MemoryStream())
{
if (responseStream == null)
{
return;
}
responseStream.CopyTo(stream);
stream.Position = 0;
using (var zipout = ZipFile.Read(stream))
{
using (var ms = new MemoryStream())
{
var entry = zipout["test.png"];
if (entry != null)
{
entry.Extract(ms);
}
else
{
return;
}
}
}
}
}
}