public static SafeFileHandle SafeCreateFile(string path, NativeFileAccess access, FileShare share, IntPtr security, FileMode mode, NativeFileAttributesAndFlags flags, IntPtr template) { var result = Kernel32.CreateFile(path, access, share, security, mode, flags, template); if (!result.IsInvalid && FileType.Disk != Kernel32.GetFileType(result)) { result.Dispose(); throw new NotSupportedException(string.Format(Resources.Culture, Resources.Error_NonFile, path)); } return(result); }
public static extern SafeFileHandle CreateFile(string name, NativeFileAccess access, FileShare share, IntPtr security, FileMode mode, NativeFileAttributesAndFlags flags, IntPtr template);
public static extern SafeFileHandle CreateFile(string name, NativeFileAccess access, FileShare share, IntPtr security, FileMode mode, NativeFileAttributesAndFlags flags, IntPtr template);
public static SafeFileHandle SafeCreateFile(string path, NativeFileAccess access, FileShare share, IntPtr security, FileMode mode, NativeFileAttributesAndFlags flags, IntPtr template) { var result = Kernel32.CreateFile(path, access, share, security, mode, flags, template); if (!result.IsInvalid && FileType.Disk != Kernel32.GetFileType(result)) { result.Dispose(); throw new NotSupportedException(string.Format(Resources.Culture, Resources.Error_NonFile, path)); } return result; }