Hi all
I have used ICSharpCode.SharpZipLib.Zip successfully before on zip-files that were not protected by a password. Now, I'm suppose to open a password protected zip-file.
When I try to read this zip-file using the ICSharpCode.SharpZipLib.Zip i get the following error message:
"Compression method not supported"
The mehod is of the type WinZipAES and a password is inserted. The same file is unziped successfully through WinRAR (also by inserting the password)
Code:
try
{
ZipInputStream zipStream = new ZipInputStream( inStream );
// get password, if supplied
if ((_password != null) && (_password != ""))
zipStream.Password = _password;
// this algorithm demands that the zip archive contain exactly one file
ZipEntry entry = zipStream.GetNextEntry();
if (entry == null)
throw new ApplicationException( "Input ZIP archive does not contain any files - expecting exactly one file" );
if (entry.IsDirectory)
throw new ApplicationException( "Input ZIP contains a directory - expecting exactly one file" );
// copy the compressed stream into the output stream
outStream = new MemoryStream();
byte[ buffer = new byte[4096];
int count = 0;
while ((count = zipStream.Read(buffer, 0, buffer.Length)) != 0)
outStream.Write( buffer, 0, count );
// make sure that was the one and only file
entry = zipStream.GetNextEntry();
if (entry != null)
throw new ApplicationException( "Input ZIP archive contains multiple files and/or directories - expecting exactly one file" );
zipStream.Close();
#if DEBUG
outStream.Seek( 0, SeekOrigin.Begin );
Microsoft.Samples.PipelineUtilities.FileStreamReadWrite.DumpStreamToFile( outStream, outFile );
#endif
outStream.Seek( 0, SeekOrigin.Begin );
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex);
throw;
}
I hope you guys can help me on this one since this will become a very critical issue for me.
Regards
A.H.