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