I want to read a file from a zip folder in Asp.net 2.0 using C# . actually i want something like this :
using (ZipFile zip = ZipFile.Open(@"E:\MyZipFolder.ZIP", FileAccess.Read))
{
// Read the central directory collection
List<ZipFile.ZipFileEntry> dir = zip.ReadCentralDir();
// Look for the desired file
foreach (ZipFile.ZipFileEntry entry in dir)
{
if (Path.GetFileName(entry.FilenameInZip) == "MyZipFile.jpg")
{
// File found, extract it
zip.ExtractStoredFile(entry, @"E:\ExtractFolder\MyZipFile.jpg");
break;
}
}
}
ZipFile is unknown , is there any suggestion?
Have a look into DotNetZip Library instead.
To use the zip capability in your applications, you need to be using the .NET Framework 2.0 or later, and you need the DotNetZip Devkit assembly.
Edit : To extract a file by name:
From http://dotnetzip.herobo.com/DNZHelp/Index.html# "Navigation: Code Examples -> C#"
using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
ZipEntry e = zip["MyReport.doc"];
e.Extract(OutputStream);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.