public static SafeFileHandle CreateSafeFileHandle( this IStorageFolder rootDirectory, string relativePath, FileMode mode, FileAccess access, FileShare share = FileShare.Read, FileOptions options = FileOptions.None) { if (rootDirectory == null) { throw new ArgumentNullException(nameof(rootDirectory)); } if (relativePath == null) { throw new ArgumentNullException(nameof(relativePath)); } HANDLE_CREATION_OPTIONS creationOptions = FileModeToCreationOptions(mode); HANDLE_ACCESS_OPTIONS accessOptions = FileAccessToHandleAccessOptions(access); HANDLE_SHARING_OPTIONS sharingOptions = FileShareToHandleSharingOptions(share); HANDLE_OPTIONS handleOptions = FileOptionsToHandleOptions(options); IStorageFolderHandleAccess handleAccess = ((object)rootDirectory) as IStorageFolderHandleAccess; if (handleAccess == null) { return(null); } SafeFileHandle handle; int result = handleAccess.Create( relativePath, creationOptions, accessOptions, sharingOptions, handleOptions, IntPtr.Zero, out handle); if (result != 0) { throw Win32Marshal.GetExceptionForWin32Error(Win32Marshal.TryMakeWin32ErrorCodeFromHR(result), relativePath); } return(handle); }
public static SafeFileHandle CreateSafeFileHandle( this IStorageFolder rootDirectory, string relativePath, FileMode mode, FileAccess access, FileShare share = FileShare.Read, FileOptions options = FileOptions.None) { if (rootDirectory == null) { throw new ArgumentNullException(nameof(rootDirectory)); } if (relativePath == null) { throw new ArgumentNullException(nameof(relativePath)); } HANDLE_CREATION_OPTIONS creationOptions = FileModeToCreationOptions(mode); HANDLE_ACCESS_OPTIONS accessOptions = FileAccessToHandleAccessOptions(access); HANDLE_SHARING_OPTIONS sharingOptions = FileShareToHandleSharingOptions(share); HANDLE_OPTIONS handleOptions = FileOptionsToHandleOptions(options); IStorageFolderHandleAccess handleAccess = rootDirectory.As <IStorageFolderHandleAccess>(); if (handleAccess == null) { return(null); } return(handleAccess.Create( relativePath, creationOptions, accessOptions, sharingOptions, handleOptions, IntPtr.Zero)); }
public int Create([NativeTypeName("LPCWSTR")] ushort *fileName, HANDLE_CREATION_OPTIONS creationOptions, HANDLE_ACCESS_OPTIONS accessOptions, HANDLE_SHARING_OPTIONS sharingOptions, HANDLE_OPTIONS options, IOplockBreakingHandler *oplockBreakingHandler, [NativeTypeName("HANDLE *")] IntPtr *interopHandle) { return(((delegate * unmanaged <IStorageFolderHandleAccess *, ushort *, HANDLE_CREATION_OPTIONS, HANDLE_ACCESS_OPTIONS, HANDLE_SHARING_OPTIONS, HANDLE_OPTIONS, IOplockBreakingHandler *, IntPtr *, int>)(lpVtbl[3]))((IStorageFolderHandleAccess *)Unsafe.AsPointer(ref this), fileName, creationOptions, accessOptions, sharingOptions, options, oplockBreakingHandler, interopHandle)); }