I want to change this label:
In the above picture I changed it manually without any permissions.
I tryed the following as said in this thread but it gives an System.UnauthorizedAccessException
public void setVolumeLabel(String oldName, string newLabel){
DriveInfo[] allDrives = DriveInfo.GetDrives();
foreach (DriveInfo d in allDrives){
if (d.IsReady && d.Name.Equals(oldName)){
d.VolumeLabel = newLabel;
}
}
So the VolumeLabel property is not what I'm looking for. Then I read this post, but can't import the Shell32.dll for some reason, it says Axlmp.exe cannpt be found.
Tried also with SetVolumeName(). It returns nonzero numbers, but doesn't change de VolumeName.
[DllImport("kernel32.dll", SetLastError=true)]
public static extern bool SetVolumeLabel(String letter, String label);
[DllImport("kernel32.dll")]
public static extern uint GetLastError();