繁体   English   中英

如何将MemoryStream转换为FileStream?

[英]How convert MemoryStream to 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**
    {
    }
}

如何转换?

在不了解您正在使用的ZipInputStream ,我唯一可以冒险的猜测是它正在尝试使用您正在将该流的位置重置为开头之前传递的MemoryStream 尝试在代码段之前添加此行:

memoryStream.Seek(0, SeekOrigin.Begin);
FileStream fs = new Filestream();

调用new Filestream(); 是不正确的。 FileStream没有任何带零参数的构造函数。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM