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);
                }
            }
        }
Exemplo n.º 2
0
        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;
                }
            }
        }