Click here to Skip to main content
15,877,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear All,

Here I came with a trouble. I have a zip file in my server. I am not suppose to download that zip file to extract its contents.

Eg., "test.zip" contains folder "test" with files "test1.jpg" & "test2.jpg".

I should not download "test.zip" folder but I should find files inside test folder placed inside that "test.zip".

If files available then I should download that jpg files and place it in my application path.

If this question is clear please help me to get out from this problem. I tried in net but I nothing to help me. Please help ASAP.
Posted

Start by looking at ZSharpLib[^] - it's pretty flexible about where the file is.

However, if the zip file is on a server, you will need direct access to the folder containing the file, and at least read permissions on that folder.
 
Share this answer
 
My preferred and simple way ( as far I know) is through DotNetZip.
Through this you not only can read but also can manipulate files like add file, delete file etc.

However, since .Net 4.5 there a is method called ZipFile.OpenRead() through which you can read files.
Something like -
C#
string zipPath = @"c:\example\start.zip";
            using (ZipArchive archive = ZipFile.OpenRead(zipPath))
            {
                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    Response.WriteLine(entry.FullName);
                }
            }

Hope, it helps :)

Reference:
http://dotnetzip.codeplex.com/[^]
https://msdn.microsoft.com/en-us/library/system.io.compression.zipfile.openread%28v=vs.110%29.aspx[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900