IsZipFile(Stream stream, bool testExtract)
{
if (stream == null)
{
);
}
bool flag = false;
try
{
if (!stream.CanRead)
{
return false;
}
Stream @null = Stream.Null;
using (ZipFile file = Read(stream, null, null, null))
{
if (testExtract)
{
foreach (ZipEntry entry in file)
{
if (!entry.IsDirectory)
{
entry.Extract(@null);
}
}
}
}
flag = true;
}
catch (IOException)
{
}
catch (ZipException)
{
}
return flag;
}
private static ZipFile Read(Stream zipStream, TextWriter statusMessageWriter, Encoding encoding, EventHandler<ReadProgressEventArgs> readProgress) { if (zipStream == null) { ); } ZipFile zf = new ZipFile { _StatusMessageTextWriter = statusMessageWriter, _alternateEncoding = encoding ?? DefaultEncoding, _alternateEncodingUsage = ZipOption.Always }; if (readProgress != null) { zf.ReadProgress += readProgress; } zf._readstream = (zipStream.Position == 0L) ? zipStream : new OffsetStream(zipStream); zf._ReadStreamIsOurs = false; if (zf.Verbose) { zf._StatusMessageTextWriter.WriteLine(); } ReadIntoInstance(zf); return zf; }