You can download it here :
http://www.icsharpcode.net/OpenSource/SharpZipLib/
to use it just add sharpZipLib.dll reference in your project, and then create a function to extract it.
Here are my function to extract the zip file :
public ArrayList ExtractZipFile(string zipFileName, string extractFolder)
{
FileStream inputZipStream = new FileStream(zipFileName,FileMode.Open);
ArrayList fileNameList = new ArrayList();
try
{
ZipInputStream zipStream = new ZipInputStream(inputZipStream);
ZipEntry entryFile = null;
//loop for all the file in zip
while((entryFile = zipStream.GetNextEntry()) != null)
{
FileStream outPutStream = new FileStream(extractFolder + entryFile.Name ,FileMode.Append);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = zipStream.Read(data, 0, data.Length);
if (size > 0)
{
outPutStream.Write(data, 0, size);
}
else
{
break;
}
}
outPutStream.Close();
fileNameList.Add(entryFile.Name);
}
}
catch(Exception ex)
{
throw ex;
}
finally
{
inputZipStream.Close();
}
return fileNameList;
}
No comments:
Post a Comment