How to convert MemoryStream to FileStream?

- Job:

using (ZipInputStream s = new ZipInputStream(File.OpenRead(zipFile)))
{
  ZipEntry theEntry;
  while ((theEntry = s.GetNextEntry()) != null)
  {
  }
}

not working memystream

using (ZipInputStream s = new ZipInputStream(memorystream))
{
    ZipEntry theEntry;
    while ((theEntry = s.GetNextEntry()) != null)//Exception **EOF in header**
    {
    }
}

how to convert?

+3
source share
2 answers

Without knowing more about ZipInputStreamwhich one you are using, the only thing I can be afraid of is that it is trying to use the MemoryStreamone you are transmitting before the position of this stream was reset to the beginning. Try adding this line before the code snippet:

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

The call is new Filestream();incorrect. FileStreamhas no constructors that accept null arguments.

+2
source

Source: https://habr.com/ru/post/1781745/


All Articles