How to handle .zip files as directories in C #?

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

+4
source share
4 answers

There are some components that let you view the contents of a .zip file from your .NET application:

I used #ziplib before, and it worked great for my purposes, which were not too extensive.

+3
source

I recently opened my Platform.VirtualFileSystem C # library.

https://github.com/platformdotnet/Platform.VirtualFileSystem https://github.com/platformdotnet/Platform.VirtualFileSystem/wiki

You can read zip files as follows:

var directory = FileSystemManager.Default.ResolveDirectory("zip://[file:///c:/test.zip]/"); directory.GetFiles().ForEach(Console.WriteLine); 

Available from NuGet: http://nuget.org/packages/Platform.VirtualFileSystem.Providers.Zip/

+2
source

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

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

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

Keep in mind that when compressing the required files, if you compress a folder, this folder will be the first entry. Not a problem, but if you want to have a clear list, write it down without folders.

Also supports encrypted passwords.

0
source

You will need to write or find a shell that is a virtual file system.

Api can be as simple as the singe public Stream GetFile(string path) method or as complex as a full FS.

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

I wrote a simple compressed VFS using the Cheeso DotNetZip library and it works fine.

0
source

Source: https://habr.com/ru/post/1307812/


All Articles