Can I find out how many partitions and their names have a C # drive?

I need to recognize from an application in .NET if the drive has a specific partition without Windows. Can this be obtained from C #? Logically, I just need to know if the section is present, I do not need to read it.

Thank you very much in advance.

+3
source share
3 answers

Here are some prototypes of C # classes to get you started:

How: (almost) everything in WMI through C # - part 3: hardware http://www.codeproject.com/KB/cs/EverythingInWmi03.aspx?msg=2310667

There is also this:
Detailed Analysis of WMI and Toolkit: Part II

+2
source

, System.Management.ManagementObject WMI. WMI

Win32_DiskDrive
Win32_DiskPartition
Win32_LogicalDisk

.

+2

Based on this article , I would suggest that you can use System.Management, as suggested above. Using the Win32_DiskPartition key, you can count the number of partitions returned. Sort of

ManagementObjectSearcher mos = new ManagementObjectSearcher("select * from " + "Win32_DiskPartition");
ManagementObjectCollection moc = mos.Get();

MessageBox.Show("Number of partitions" + moc.Count);
+1
source

Source: https://habr.com/ru/post/1713552/


All Articles