public void Unzip(string sourceFile)
{
zipInputStream = new ZipInputStream(File.OpenRead(sourceFile));
ZipEntry entry;
string tmpEntry = String.Empty;
while ((entry = zipInputStream.GetNextEntry()) != null)
{
string fileName = Path.GetFileName(entry.Name);
// create directory
string outputFolder = Path.GetDirectoryName(sourceFile) + "\\" +
Path.GetFileNameWithoutExtension(sourceFile);
if (fileName != String.Empty)
{
string fullPath = outputFolder + "\\" + entry.Name;
fullPath = fullPath.Replace("\\ ", "\\");
string fullDirPath = Path.GetDirectoryName(fullPath);
if (!Directory.Exists(fullDirPath)) Directory.CreateDirectory(fullDirPath);
FileStream streamWriter = File.Create(fullPath);
int size = 2048;
byte[] data = new byte[2048];
while (true)
{
size = zipInputStream.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
zipInputStream.Close();
}