tags:

views:

97

answers:

4

I want to be able to be able to read files in zip files just as I would read files in a physical folder. How can I do this without having to extract the files?

A: 

If you want to do anything other than read the directory structure of the zip file, you're going to have to extract the file to a temp location and then read it from there.

...even the commercial applications do things that way.

Justin Niessner
Justin, most zip libs allow extraction of an entry from the source without extracting to disk. If I understand your answer, then your answer is wrong or incomplete. Cheers.
Sky Sanders
+2  A: 

There are some components out there that allow you to view the contents of a .zip file from your .NET application:

I've used the #ziplib before and it worked fine for my purposes which weren't too extensive.

dana
A: 

First of all .NET although it supports compressed files it does not support ZIP files (not sure about .NET v4)

Anyhow I used SharpZipLib http://www.icsharpcode.net/OpenSource/SharpZipLib/ (GPL +exceptions read carefully)

This library allows you to go through the ZipStream and get access to the ZipEntry which gives you all the file information.

Have in mind that when compressing the files you want, if you compress a folder the first entry will be that folder. Not a problem, but if you wish to have a clear list, zip it without folders paths.

Also supports passworded zips.

ruralcoder
A: 

You will need to write or find a wrapper that presents itself as a virtual file system.

The api could be as simple as a singe public Stream GetFile(string path) method or as complex as a full FS.

This is possible using any compression lib that supports the file format you would like to use.

I have written a simple compressed VFS using Cheeso's DotNetZip library and it works just fine.

Sky Sanders