/// <summary> /// Initializes a new instance of the VolumeDeviceClass class. /// </summary> public VolumeDeviceClass() : base(new Guid(Native.GUID_DEVINTERFACE_VOLUME)) { foreach (string drive in Environment.GetLogicalDrives()) { StringBuilder sb = new StringBuilder(1024); if (Native.GetVolumeNameForVolumeMountPoint(drive, sb, sb.Capacity)) { _logicalDrives[sb.ToString()] = drive.Replace("\\", ""); } } }
/// <summary> /// Initializes a new instance of the VolumeDeviceClass class. /// </summary> public VolumeDeviceClass() : base(new Guid(Native.GUID_DEVINTERFACE_VOLUME)) { DriveInfo[] driveInfos = System.IO.DriveInfo.GetDrives(); foreach (DriveInfo drive in driveInfos) { if (drive.DriveType == DriveType.Network) { continue; } StringBuilder sb = new StringBuilder(1024); if (Native.GetVolumeNameForVolumeMountPoint(drive.Name, sb, sb.Capacity)) { _logicalDrives[sb.ToString()] = drive.Name.Replace("\\", ""); Console.WriteLine(drive + " ==> " + sb); } } }