protected override void Dispose(bool disposing)
{
if (_disposed) return;
if (disposing) // not called from finalizer
{
// handle pending exceptions
if (!_exceptionPending)
{
_FinishCurrentEntry();
_directoryNeededZip64 = ZipOutput.WriteCentralDirectoryStructure(_outputStream,
_entriesWritten.Values,
1, // _numberOfSegmentsForMostRecentSave,
_zip64,
Comment,
new ZipContainer(this));
Stream wrappedStream = null;
CountingStream cs = _outputStream as CountingStream;
if (cs != null)
{
wrappedStream = cs.WrappedStream;
#if NETCF
cs.Close();
#else
cs.Dispose();
#endif
}
else
{
wrappedStream = _outputStream;
}
if (!_leaveUnderlyingStreamOpen)
{
#if NETCF
wrappedStream.Close();
#else
wrappedStream.Dispose();
#endif
}
_outputStream = null;
}
}
_disposed = true;
}