public void SetVolumeLabel(string newLabel)
{
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives)
{
if (d.IsReady && d.DriveType == DriveType.Removable)
{
d.VolumeLabel = newLabel;
}
}
}
public string VolumeLabel { get; set; }
// Setting the drive name
private void button1_Click(object sender, EventArgs e)
{
SetVolumeLabel("FlashDrive");
}
但是,它不适用于虚拟驱动器。如何更改由 SUBST 命令创建的虚拟驱动器的卷标?