0

I have a application that I want to copy directories within a internal ZIP to a path.

Did some searching and found this: Decompress byte array to string via BinaryReader yields empty string. However, the result is simply bytes. I haven't a clue about how to translate this back into folders that can then be moved to a path. (Working with just bytes is confusing to me)

Doing some more searching on here pointed me to the .NET 4.5 feature: https://learn.microsoft.com/en-us/dotnet/standard/io/how-to-compress-and-extract-files

There's one complication, I don't have a zip path, rather a array of bytes from the zip kept internally inside my application. Keeping this in mind, how would I go about using this ZipFile feature but instead with a array of bytes as a input?

Some other things I've looked at:

Note, for this particular application, I'd like to refrain from using external DLL's. A portable CLI executable is what I'm aiming for.

Jacob Jewett
  • 349
  • 2
  • 4
  • 18
  • 1
    `ZipArchive` works on streams, so wrap your bytes in a `MemoryStream` and decompress from that. Your question is too broad, so there's no point in trying to answer it. You should _try something_ and post a question when you have something _specific_ to ask. – Peter Duniho Jan 07 '18 at 05:33
  • I just did some looking at MSDN's page on `MemoryStream`. I don't know how or what you mean by "wrap your bytes". Can I have a example? – Jacob Jewett Jan 07 '18 at 06:07
  • You might consider acquainting yourself with the search tools available on the Internet, and even on this very web site. https://stackoverflow.com/search?q=%5Bc%23%5D+ziparchive+memorystream – Peter Duniho Jan 07 '18 at 06:08

1 Answers1

0

In order to satisfy both the need that I have only bytes and unzip the bytes (without using MemoryBuffer as that still makes no sense to me), I ended up creating a temporary folder, creating a empty file in that folder, filling it with the bytes of the zipped file then using ZipFile.ExtractToDirectory() to extract it to the final destination. It may not be the most efficient, but it works quite well.

Jacob Jewett
  • 349
  • 2
  • 4
  • 18