Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

content inside zip file

Tags:

c#

.net

zip

how to find list of files inside zip file without unzipping it in c#.

like image 311
Niraj Choubey Avatar asked Jul 03 '10 07:07

Niraj Choubey


People also ask

What are the contents of a zip file?

They contain data and files together in one place. But with zipped files, the contents are compressed, which reduces the amount of data used by your computer. Another way to describe ZIP files is as an archive. The archive contains all the compressed files in one location.

How do I see what's inside a zip file?

Also, you can use the zip command with the -sf option to view the contents of the . zip file. Additionally, you can view the list of files in the . zip archive using the unzip command with the -l option.

How can I read a zip file without unzipping it?

Using Vim. Vim command can also be used to view the contents of a ZIP archive without extracting it. It can work for both the archived files and folders. Along with ZIP, it can work with other extensions as well, such as tar.

Can you edit files within a zip file?

In some use cases documents may be placed inside zip files, which can be part of multifile document. If user wants to edit some of documents inside zip in M-Files, it is not necessary to copy zip file to computer. Editing inside zip can be done also directly in M-Files.


2 Answers

With sharpziplib:

ZipInputStream zip = new ZipInputStream(File.OpenRead(path));
ZipEntry item;
while ((item = zip.GetNextEntry()) != null)
{
    Console.WriteLine(item.Name);
}
like image 81
Marc Gravell Avatar answered Oct 03 '22 09:10

Marc Gravell


There is a simple way to do this with sharpziplib :

        using (var zipFile = new ZipFile(@"C:\Test.zip"))
        {
            foreach (ZipEntry entry in zipFile)
            {
                Console.WriteLine(entry.Name);
            }
        }
like image 32
user2776545 Avatar answered Oct 03 '22 08:10

user2776545