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

标签 vb.net drop-down-menu mapping

使用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/

相关文章:

vb.net - 如何在 VB.NET 中为 CheckedListBox 项目着色?

CSS 菜单向上?

javascript - jQuery 中下拉搜索框的模糊问题

entity-framework - 不确定如何映射多对多关系 - 重用不同实体的映射表

java - 如何分离dto映射逻辑

vb.net - 如何在 c1flexgrid 中通过代码设置 DataField 属性

vb.net - 如何在 VB.net Winforms 中拥有所有形式的一个菜单?

.net - 数据透视缓存类型不匹配错误 VB.NET Excel

drop-down-menu - Nivo slider 覆盖了我的下拉菜单,它是 z-index 吗?

javascript - 使用数组向对象添加属性