4

我想知道如何在 MVC 中选择目标文件夹的目录,如文件夹浏览器对话框?

喜欢这张图片http://www.codeguru.com/img/legacy/files/getFolder1.gif

例如,如果我选择一个文件夹,我想获取 \Server\Folder1\Folder11 之类的路径

谢谢!

4

1 回答 1

0

可能是这个?

你可以在那里找到一些聊天

http://www.eggheadcafe.com/community/csharp/2/10116970/accessing-shared-folder-on-a-network-using-c-code.aspx

片段1:

List<string> mappedDrives = new List<string>();
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drvInfo in drives)
{
          if (drvInfo.DriveType == DriveType.Network)
            mappedDrives.Add(drvInfo.Name);
}

片段 2:

ManagementScope mgmtScope = new ManagementScope();
//query for drivetype = 4..for  network drive
ObjectQuery objQuery = new ObjectQuery("SELECT VolumeName FROM Win32_LogicalDisk   WHERE DriveType= 4");
ManagementObjectSearcher mgmgObjSearch = new ManagementObjectSearcher(mgmtScope,   objQuery);
ManagementObjectCollection mgmgObjColl = mgmgObjSearch.Get();
foreach (ManagementObject mgmgObj in mgmgObjColl)
{
    mappedDrives.Add(mgmgObj["VolumeName"].ToString());
}
于 2012-05-31T00:38:23.593 回答