// Write "closed" entries to the archive. private void Flush() { ExceptionContext.Assert(!Disposed); ExceptionContext.AssertValue(_closed); ExceptionContext.AssertValue(_archive); while (_closed.Count > 0) { string path = null; var kvp = _closed.Dequeue(); using (var src = kvp.Value) { var fs = src as FileStream; if (fs != null) { path = fs.Name; } var ae = _archive.CreateEntry(kvp.Key); using (var dst = ae.Open()) { src.Position = 0; src.CopyTo(dst); } } if (!string.IsNullOrEmpty(path)) { File.Delete(path); } } }
protected override void Dispose(bool disposing) { ExceptionContext.Assert(!Disposed); if (_closed != null) { while (_closed.Count > 0) { var kvp = _closed.Dequeue(); kvp.Value.CloseEx(); } _closed = null; } if (_archive != null) { try { _archive.Dispose(); } catch { } _archive = null; } // Close all the streams. base.Dispose(disposing); }