Microsoft.VisualBasic.Compatibility 中 DirListBox 和/或 FileListBox 的替换

jmo*_*eno 4 .net vb6-migration .net-4.5

我有一个已迁移到 VB.net 的 VB6 应用程序,并且正在尝试将框架版本升级到 4.5 - 它抱怨 Microsoft.VisualBasic.Compatibility dll 中的所有内容都已过时。我能够相当轻松地替换除 FileListBox 和 DirListBox 之外的所有内容 - 虽然很乏味,但我不必创建任何新控件。

这些控件有相近的替代品吗?有谁知道它们是否已与框架的其余部分一起开源?

小智 5

您可以使用简单的ListBox控件并使用My.Computer.FileSystem将它们制作为旧的DriveListBox、DirectoryListBox和FileListBox。你可以使用类似下面的东西

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    lstDriveList.DataSource = My.Computer.FileSystem.Drives
End Sub

Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstDriveList.SelectedIndexChanged
    lstDirectoryList.DataSource = My.Computer.FileSystem.GetDirectories(lstDriveList.SelectedValue.ToString())
End Sub


Private Sub lstDirectoryList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles lstDirectoryList.SelectedIndexChanged
    lstFileList.DataSource = My.Computer.FileSystem.GetFiles(lstDirectoryList.SelectedValue.ToString())
End Sub
Run Code Online (Sandbox Code Playgroud)

所有lst都只是普通的ListBox,您也可以使用ListView控件,类似的方式。