Hi,
Try this code, this will solve your problem. I have tested this to unzip 900MB file.
protected void btnUnzip_Click(object sender, EventArgs e)
{
StringBuilder newPath = new StringBuilder();
newPath.Append(@"D:\Test\");
string zipPathAndFile = @"F:\EnglishBook.zip";
ZipInputStream zipIn = new ZipInputStream(File.OpenRead(zipPathAndFile));
DecompressArchive(newPath, zipIn);
}
public static void DecompressArchive(StringBuilder newPath, ZipInputStream zipIn)
{
ZipEntry entry;
while ((entry = zipIn.GetNextEntry()) != null)
{
if (entry.Name.EndsWith("/"))
{
Directory.CreateDirectory(String.Format("{0}{1}", newPath, entry.Name.Replace(@"/", @"\")));
}
else
{
FileStream streamWriter = File.Create(String.Format("{0}{1}", newPath, entry.Name.Replace(@"/", @"\")));
int size = 1024 * 10;
Byte[] data = new Byte[size];
while (true)
{
size = zipIn.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, (int)size);
}
else break;
}
streamWriter.Close();
}
}
}
Note: Only thing, I have changed is size of chunk.
int size = 1024 * 10;
Thanks,