internal static unsafe SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize)
        {
            using (DisableMediaInsertionPrompt.Create())
            {
                SafeFileHandle fileHandle = new SafeFileHandle(
                    NtCreateFile(fullPath, mode, access, share, options, preallocationSize),
                    ownsHandle: true,
                    options);

                fileHandle.InitThreadPoolBindingIfNeeded();

                return(fileHandle);
            }
        }
示例#2
0
        internal static unsafe SafeFileHandle Open(string fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, long preallocationSize)
        {
            using (DisableMediaInsertionPrompt.Create())
            {
                // we don't use NtCreateFile as there is no public and reliable way
                // of converting DOS to NT file paths (RtlDosPathNameToRelativeNtPathName_U_WithStatus is not documented)
                SafeFileHandle fileHandle = CreateFile(fullPath, mode, access, share, options);

                if (FileStreamHelpers.ShouldPreallocate(preallocationSize, access, mode))
                {
                    Preallocate(fullPath, preallocationSize, fileHandle);
                }

                fileHandle.InitThreadPoolBindingIfNeeded();

                return(fileHandle);
            }
        }