protected override void Dispose(bool disposing) { FlushInternal(); long position = Position; if (m_stream != null) { m_stream.Dispose(); m_stream = null; } if (m_buffer != null) { m_buffer.Dispose(); m_buffer = null; } // set the correct length // this really isn't necessary for intermediate files (segments) if (m_truncateOnClose) { long length = m_actualLength > 0 ? m_actualLength : position; using (var stream = new FileStream(m_path, FileMode.Open, FileAccess.Write, FileShare.None, 8, FileOptions.WriteThrough)) { stream.SetLength(length); } } }
public void Dispose() { if (!StreamManager.IsSharedStream(this)) { if (m_stream != null) { m_stream.Dispose(); m_stream = null; } if (m_streamEnd != null) { m_streamEnd.Dispose(); m_streamEnd = null; } if (m_buffer != null) { m_buffer.Dispose(); m_buffer = null; } } }