internal WindowsFileStreamStrategy(string path, FileMode mode, FileAccess access, FileShare share, FileOptions options) { string fullPath = Path.GetFullPath(path); _path = fullPath; _access = access; _share = share; _fileHandle = FileStreamHelpers.OpenHandle(fullPath, mode, access, share, options); try { _canSeek = true; Init(mode, path); } catch { // If anything goes wrong while setting up the stream, make sure we deterministically dispose // of the opened handle. _fileHandle.Dispose(); _fileHandle = null !; throw; } }
internal LegacyFileStreamStrategy(string path, FileMode mode, FileAccess access, FileShare share, int bufferSize, FileOptions options) { string fullPath = Path.GetFullPath(path); _path = fullPath; _access = access; _bufferLength = bufferSize; if ((options & FileOptions.Asynchronous) != 0) { _useAsyncIO = true; } _fileHandle = FileStreamHelpers.OpenHandle(fullPath, mode, access, share, options); try { Init(mode, share, path, options); } catch { // If anything goes wrong while setting up the stream, make sure we deterministically dispose // of the opened handle. _fileHandle.Dispose(); _fileHandle = null !; throw; } }