DEV Community

Cover image for See what's inside a ZIP file
Atir Tahir
Atir Tahir

Posted on

See what's inside a ZIP file

Suppose you are working with the ZIP files all the time. Let's call it your business/job routine or process. Someone uploads ZIP files everyday to the server and you have to find specific documents in them.
Normally, you would download the ZIP files and extract them or open them using any archiving tool (e.g. WinZip) and look for the right ZIP that contains the required file(s).

How about getting compressed files information without downloading them?
Suppose, you have 20+ different formatted files compressed in DailyFiles.ZIP.

Alt Text

This is how you can view the compressed files in your Web application (there's no need to download the ZIP):

Alt Text

Have a look at the code below:

string outputDirectory = @"D:/";
string pageFilePathFormat = Path.Combine(outputDirectory, "page_{0}.html");
using (Viewer viewer = new Viewer(@"D:/DailyFiles.zip"))
{
    HtmlViewOptions options = HtmlViewOptions.ForEmbeddedResources(pageFilePathFormat);  
    viewer.View(options);
} 
Enter fullscreen mode Exit fullscreen mode

This document viewer API basically renders the source file into HTML. Later, this resultant HTML could be displayed in the browser or any other application (e.g. Desktop). In case of any issue for further details, you can raise your concerns here.

Top comments (0)