Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DotNetZip: Convert ZipFile to byte[] array

Tags:

c#

byte

dotnetzip

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;
}
like image 200
okello Avatar asked Jun 20 '12 12:06

okello


1 Answers

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

return File.ReadAllBytes( shapeFileZip.Name );

To read from your file.

like image 51
Uwe Keim Avatar answered Oct 20 '22 20:10

Uwe Keim