gpt4 book ai didi

vb.net - 在下拉列表中获取所有映射的网络驱动器

转载 作者:行者123 更新时间:2023-12-04 04:06:45 25 4
gpt4 key购买 nike

使用VB.Net是否可以在下拉列表中列出所有映射的网络目录/驱动器?

我已经瞥了一眼,但是找不到任何有用的..

最佳答案

要将其添加到DropDownList中:

 Private Sub TestCase1()
Dim drive As System.IO.DriveInfo

For Each drive In System.IO.DriveInfo.GetDrives()
If drive.DriveType = IO.DriveType.Network Then
DropDownList1.Items.Add(drive.Name)
End If
Next
End Sub

这就是我在C#中的处理方式:
private void TestCase1()
{

//Recurse through the drives on this system and add them to the new DropDownList DropDownList1 if they are a network drive.
foreach(System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
//This check ensures that drive is a network drive.
if (drive.DriveType == System.IO.DriveType.Network)
{
//If the drive is a network drive we add it here to a combobox.
DropDownList1.Items.Add(drive);
}
}
}

关于vb.net - 在下拉列表中获取所有映射的网络驱动器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12689185/

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