5

I'm using DotNetZip to add a file to a zip archive, which I've read from the file system. I'd like to convert the resulting ZipFile to byte[] array. Any assistance will be highly appreciated. My code is shown below.

public byte[] AddPrjFile(FileStream shapeFileZip, Uri prjLocation)
{
    string prjFileAbsPath = prjLocation.AbsolutePath;
    using (ZipFile zip = ZipFile.Read(shapFileZip))
    {
        ZipEntry e = zip.AddFile(prjFileAbsPath);
        e.FileName = zipFile.Name + ".prj";
    }

    return byte_array;
}
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
okello
  • 601
  • 10
  • 27

1 Answers1

13

You could simply use the File.ReadAllBytes static method like:

return File.ReadAllBytes( shapeFileZip.Name );

To read from your file.

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291