/// <summary> /// Populates internal properties from WMI.</summary> private void GetLogicalDriveInformation() { var w32LogicalDisk = new ManagementObjectSearcher("root\\CIMV2", $"SELECT * FROM Win32_LogicalDisk WHERE Name = '{MountPoint.Replace("\\", "") }'").Get(); if (w32LogicalDisk.Count == 0) // No drive with this letter was found, exit function { return; } foreach (var drive in w32LogicalDisk) { // Since we are querying with a drive letter, the collection can only contain a single object this.Size = ulong.Parse(drive["Size"].ToString()); this.SerialNumber = drive["VolumeSerialNumber"].ToString().Trim(); this.Type = (DriveType)Enum.Parse(typeof(DriveType), drive["DriveType"].ToString()); this.VolumeName = drive["VolumeName"].ToString(); } }