Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public static extern SafeFileHandle CreateFile(string name, NativeFileAccess access, FileShare share, IntPtr security, FileMode mode,
     NativeFileAttributesAndFlags flags, IntPtr template);
Exemplo n.º 3
0
 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;
 }