1

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)
                    mappedDrivesNames.Add(drive.VolumeLabel);
            }

But it return the name of the first shared folder from the list on server. Any ideas, why this happened?

mike
  • 23
  • 4
  • Interesting question. "Network Drive" isn't the label of the drive. Windows Explorer shows "Network Drive" as the drive's type. In a command box, the `label z:` command would show the actual label of the volume the drive is connected to. – comecme Dec 16 '10 at 08:35

1 Answers1

0

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.

comecme
  • 6,086
  • 10
  • 39
  • 67