加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-17 00:19:16 所属栏目:大数据 来源:网络整理
导读:使用VB.Net是否可以在下拉列表中列出所有映射的网络目录/驱动器? 我有眼罩,但找不到任何有用的东西.. 要将它添加到DropDownList: Private Sub TestCase1() Dim drive As System.IO.DriveInfo For Each drive In System.IO.DriveInfo.GetDrives() If drive.
使用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);
            }
        }
    }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读