Exemplo n.º 1
0
        /// <summary>
        /// Gets the file stream.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="access">The access.</param>
        /// <param name="share">The share.</param>
        /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
        /// <returns>FileStream.</returns>
        public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false)
        {
            if (_sharpCifsFileSystem.IsEnabledForPath(path))
            {
                return(_sharpCifsFileSystem.GetFileStream(path, mode, access, share));
            }

            if (_supportsAsyncFileStreams && isAsync)
            {
                return(GetFileStream(path, mode, access, share, FileOpenOptions.Asynchronous));
            }

            return(GetFileStream(path, mode, access, share, FileOpenOptions.None));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the file stream.
        /// </summary>
        /// <param name="path">The path.</param>
        /// <param name="mode">The mode.</param>
        /// <param name="access">The access.</param>
        /// <param name="share">The share.</param>
        /// <param name="isAsync">if set to <c>true</c> [is asynchronous].</param>
        /// <returns>FileStream.</returns>
        public Stream GetFileStream(string path, FileOpenMode mode, FileAccessMode access, FileShareMode share, bool isAsync = false)
        {
            if (_sharpCifsFileSystem.IsEnabledForPath(path))
            {
                return(_sharpCifsFileSystem.GetFileStream(path, mode, access, share));
            }

            if (_supportsAsyncFileStreams && isAsync)
            {
                return(new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 262144, true));
            }

            return(new FileStream(path, GetFileMode(mode), GetFileAccess(access), GetFileShare(share), 262144));
        }