Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi,

I am in trouble of extracting a specific file from a .zip file.
I want to extract one known file from a.zip file. I know the file(known.txt) exist in that .zip(test.zip) file, so i just want to extract the file to temporary location without any search or going through the entire zip.

It would be great if someone help me on this one.

Regards, Surya
Posted

1 solution

Hi
You can use the below code, it only support in Framework 4.5

C#
ZipArchive zFile = ZipFile.OpenRead("test.zip");
ZipArchiveEntry entry;
entry = zFile.GetEntry("known.txt");
entry.ExtractToFile("known.txt",true);


msdn link http://msdn.microsoft.com/en-us/library/ms404280(v=vs.110).aspx?[^]

Regards

Afsal
 
Share this answer
 
Comments
Surya(10980329) 30-Jul-14 8:13am    
Hi Afsal,

Thank you so much for getting back.

I am using MS VS 2010 V10.0 and MS .NET Framework V4.5.50709P1Rel.

When add above code in my method it says ZipArchive couldn't found or missing assembly.

Believe ZipArchive is belongs to System.IO.Compression.FileSystem, but I can't find the dll in the project reference list.

So what I did then I have downloaded the dll for System.IO.Compression.FileSystem and added as reference into the project, however the same can't be accessible using in the project itself.

Can you please guide me here ? Many thanks.

Regards, Surya
appoos 30-Jul-14 11:36am    
You can browse to C:\Windows\Microsoft.NET\Framework\v4.0.30319\ and add System.IO.Compression.dll and System.IO.Compression.FileSystem.dll file as reference

Surya(10980329) 31-Jul-14 2:14am    
Thank you so much. It is working now.

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