Hello,
i have encountered a bug when trying to decompress an archiv.
Heres my Code:
public static bool Unzip(string file, string dir)
{
if (!Directory.Exists(dir))
Directory.CreateDirectory(dir);
ZipInputStream s = new ZipInputStream(File.OpenRead(file));
ZipEntry theEntry;
while ((theEntry = s.GetNextEntry()) != null)
{
string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);
if (directoryName != String.Empty)
Directory.CreateDirectory(dir + "\\" + directoryName);
if (fileName != String.Empty)
{
FileStream streamWriter = File.Create(dir + "\\" + theEntry.Name);
int size = 32768;
byte[ data = new byte[32768];
while (true)
{
size = s.Read(data, 0, data.Length);
if (size > 0)
{
streamWriter.Write(data, 0, size);
}
else
{
break;
}
}
streamWriter.Close();
}
}
s.Close();
return true;
}
An Archiv that causes a creashes is very easy to create:
you need 2 directories with content, and add them to the same archiv.
"%ProgramFiles(X86)%\WinRar
ar.exe" a Test.zip Server
"%ProgramFiles(X86)%\WinRar
ar.exe" a Test.zip Desktop
i could upload an archiv that crashes - but the forum does not support uploads !?