我想知道如何在MVC中选择目标文件夹的目录,例如folderbrowserdialog?
喜欢这张图片http://www.codeguru.com/img/legacy/files/getFolder1.gif
例如,如果我选择一个文件夹,我想获取路径,如\ Server \ Folder1 \ Folder11
谢谢!
答案 0 :(得分:0)
可能是这个吗?
有些聊天你可以在那里找到
代码段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());
}