Changing and setting drive lebels via C#
Could anyone out there provide some insight into how to alter drive labels via C# using WMI or something else?
To clarify, in an explorer window you will not that the C:\ drive for instance is normally labelled by default as "LOCAL DRIVE". I want to enumerate the drives on a local system, and apply specific labels to each one debending on their drive letter.

Craig MurphyRank #2,956 · 488 reputationPosted Feb 12, 2007, 5:58 AM EST
The following code snippet should solve your problem:
using System;
using System.IO;
...
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
// If it's the D:\
if (d.Name == "D:\\")
{
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine(" File type: {0}", d.DriveType);
Console.WriteLine(" Volume label: {0}", d.VolumeLabel);
Console.WriteLine(" File system: {0}", d.DriveFormat);
// Change the drive name
if (d.IsReady == true)
{
d.VolumeLabel = "DATA1";
}
}
}
HTH
Geoff6 reputationPosted Feb 12, 2007, 12:45 PM EST
Craig MurphyRank #2,956 · 488 reputationPosted Feb 12, 2007, 11:19 PM EST
http://www.adaptiveintelligence.net/Developers/CodeSamples/DriveInfoClass.aspx