[英]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". 因此,例如,如果我有驱动器Z:NetworkDrive,它映射到另一台服务器上的共享文件夹,并且我想返回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?
任何想法,为什么会这样?
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.
我有驱动器Z:连接到Windows XP计算机上的共享,并且共享位于NTFS格式化的驱动器上。 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. 我不知道如果共享在Linux机器上,预期的结果应该是什么。 I don't know if Linux has something like a Label, but I don't think so.
我不知道Linux是否具有类似Label的功能,但我不这么认为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.