CreateFile() private méthode

private CreateFile ( [ lpFileName, [ dwDesiredAccess, [ dwShareMode, [ lpSecurityAttributes, [ dwCreationDisposition, [ dwFlagsAndAttributes, [ hTemplateFile ) : SafeFileHandle
lpFileName [
dwDesiredAccess [
dwShareMode [
lpSecurityAttributes [
dwCreationDisposition [
dwFlagsAndAttributes [
hTemplateFile [
Résultat Microsoft.Win32.SafeHandles.SafeFileHandle
        //
        // Private Helpers
        //

        private static SafeFileHandle GetDirectoryHandle(string path)
        {
            // Get a native handle to the directory
            SafeFileHandle handle = NativeMethods.CreateFile(
                path,
                NativeMethods.FileAccess.GENERIC_WRITE,
                NativeMethods.FileShare.FILE_SHARE_NONE,
                IntPtr.Zero,
                NativeMethods.FileMode.OPEN_EXISTING,
                NativeMethods.FILE_FLAG_BACKUP_SEMANTICS, // Returns the directory handle
                IntPtr.Zero);

            if (handle.IsInvalid)
            {
                throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error());
            }

            return(handle);
        }