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