gpt4 book ai didi

c# - 如何在 C# MVC 中选择文件夹目标?

转载 作者:行者123 更新时间:2023-11-30 13:04:01 24 4
gpt4 key购买 nike

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

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

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

谢谢!

最佳答案

可能是这个?

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

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());
}

关于c# - 如何在 C# MVC 中选择文件夹目标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10825109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com