8

I am trying to take a list of ZipArchiveEntrys and convert them into byte arrays, but I am logistically running into a wall.

So far I am trying to convert it into a MemoryStream to convert it into the byte[] like this:

public static void ScanUpload(List<ZipArchiveEntry> scan)
{
    foreach (var s in scan)
    {                           
        using (var ms = new MemoryStream())
        {

        }
    }
}

But I have no idea what comes next. or even if this is the right way to go about this. Would someone be able to help?

scapegoat17
  • 5,509
  • 14
  • 55
  • 90
  • 1
    Have a look at this thread. It is really simple , http://stackoverflow.com/questions/11119705/dotnetzip-convert-zipfile-to-byte-array – EugenSunic Feb 05 '15 at 19:37

1 Answers1

20

You should be able to read from the stream that ZipArchiveEntry.Open() returns:

foreach (var s in scan)
{            
    var stream = s.Open();
    byte[] bytes;
    using (var ms = new MemoryStream())
    {
         stream.CopyTo(ms);
         bytes = ms.ToArray();
    }
}
abieganski
  • 550
  • 4
  • 9