// Dispose of this stream. protected virtual void Dispose(bool disposing) { lock (this) { if (handle != invalidHandle) { if (bufferOwnedByWrite) { FlushWriteBuffer(); } if (ownsHandle) { FileMethods.Close(handle); } handle = invalidHandle; } } }