how to get Network mapped drive VolumeLabel in C#?
So for example, if i have drive Z:NetworkDrive, which mapped to shared folder on another server, and i want to return volumelabel "NetworkDrive". Next code seems to work:
foreach (DriveInfo drive in drives)
{
if (drive.DriveType == DriveType.Network)
mappe开发者_JAVA百科dDrivesNames.Add(drive.VolumeLabel);
}
But it return the name of the first shared folder from the list on server. Any ideas, why this happened?
If I just code
var drive = new DriveInfo("Z");
Console.WriteLine(drive.VolumeLabel);
It is showing me the Label of the Volume the network share is on. I have my drive Z: connected to a share on a Windows XP computer and the share is on a NTFS formatted drive. If I remove the label for that volume, the program will output an empty line.
I don't know what the expected result should be if the share is on a Linux machine. I don't know if Linux has something like a Label, but I don't think so.
精彩评论