How to get Drive Volume Name

  • Thread starter Thread starter Guest
  • Start date Start date
Chuck Walters said:
Is there a .net API to get the "Volume Name" of a given drive?

Use System.Management and WMI's class "Win32_LogicalDisk, something like
this will do...

using System.Management;

...

string drive= "c:";
string VolumeLabel = null;
string ObjectPath = String.Format("win32_LogicalDisk.DeviceId='{0}'",
drive);
using(ManagementObject mo = new ManagementObject(ObjectPath ))
{
mo.Get();
VolumeLabel = mo["VolumeName"];
}


Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top