public WinLogicalDisk(ManagementObject mo) { Attributes = new LogicalDiskAttributes(mo); Handle = Win32.CreateFile(@"\\.\" + Attributes.DeviceID, EFileAccess.GenericRead, EFileShare.Read | EFileShare.Write | EFileShare.Delete, IntPtr.Zero, ECreationDisposition.OpenExisting, EFileAttributes.None, IntPtr.Zero); if (Handle.IsInvalid) { throw new Exception("Failed to get a handle to the logical volume. " + Marshal.GetLastWin32Error()); } _size = Util.GetDiskSize(Handle); _fileSystem = FileSystem.TryLoad(this); }