如何将MemoryStream转换为FileStream?
是工作:
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFile)))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
}
}
不工作,内存流
using (ZipInputStream s = new ZipInputStream(memorystream))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)//Exception **EOF in header**
{
}
}
如何转换?
is work:
using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFile)))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
}
}
not work, memorystream
using (ZipInputStream s = new ZipInputStream(memorystream))
{
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)//Exception **EOF in header**
{
}
}
how convert ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在不了解有关您正在使用的 ZipInputStream 的更多信息的情况下,我唯一可以冒险的猜测是它正在尝试使用您在该流的位置之前传递给它的 MemoryStream重置到开始。尝试在代码片段之前添加此行:
Without knowing more about the
ZipInputStream
you're using, the only guess I can hazard is that it's trying to use theMemoryStream
you're passing it before that stream's position has been reset to the beginning. Try adding this line before your code snippet:对
new Filestream();
的调用不正确。FileStream
没有任何采用零参数的构造函数。The call to
new Filestream();
is incorrect.FileStream
doesn't have any constructors that take zero arguments.