Attributes of a physical disk partition. Windows only.
Inheritance: Attributes, IDescribable
示例#1
0
        public PhysicalDiskPartition(WinPhysicalDisk disk, MasterBootRecord.PartitionEntry pEntry)
        {
            PhysicalDisk = disk;
            Offset       = pEntry.PartitionOffset;
            Length       = pEntry.PartitionLength;

            ManagementScope ms = new ManagementScope();
            ObjectQuery     oq = new ObjectQuery(
                string.Format("SELECT * FROM Win32_DiskPartition WHERE DiskIndex = {0} AND Index = {1}",
                              disk.Attributes.Index, pEntry.Index));
            ManagementObjectSearcher   mos = new ManagementObjectSearcher(ms, oq);
            ManagementObjectCollection moc = mos.Get();

            if (moc.Count != 1)
            {
                throw new Exception("Unable to get partition data from WMI");
            }
            foreach (ManagementObject mo in moc)
            {
                Attributes = new PhysicalDiskPartitionAttributes(mo, disk);
                break;
            }
            Attributes.PartitionType = pEntry.PartitionType;

            _fileSystem = FileSystem.TryLoad(this as IFileSystemStore);
        }
		public PhysicalDiskPartition(WinPhysicalDisk disk, MasterBootRecord.PartitionEntry pEntry) {
			PhysicalDisk = disk;
			Offset = pEntry.PartitionOffset;
			Length = pEntry.PartitionLength;

			ManagementScope ms = new ManagementScope();
			ObjectQuery oq = new ObjectQuery(
					string.Format("SELECT * FROM Win32_DiskPartition WHERE DiskIndex = {0} AND Index = {1}",
					disk.Attributes.Index, pEntry.Index));
			ManagementObjectSearcher mos = new ManagementObjectSearcher(ms, oq);
			ManagementObjectCollection moc = mos.Get();
			if (moc.Count != 1) {
				throw new Exception("Unable to get partition data from WMI");
			}
			foreach (ManagementObject mo in moc) {
				Attributes = new PhysicalDiskPartitionAttributes(mo, disk);
				break;
			}
			Attributes.PartitionType = pEntry.PartitionType;

			_fileSystem = FileSystem.TryLoad(this as IFileSystemStore);
		}