Microsoft.VisualBasic.Compatibility 中 DirListBox and/or FileListBox 的替换

Replacements for DirListBox and/or FileListBox from Microsoft.VisualBasic.Compatibility

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

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

您可以使用简单的 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

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

不幸的是,你将不得不自己动手(就像@kman 已经把你赶走了)。

这里讨论了一些替代方案:https://social.msdn.microsoft.com/Forums/en-US/b2d13c9a-e320-4f36-981e-e4c1999d7694/vbnet-equivalent-of-vb6-code-which-are-obsolete?forum=vbinterop

有人建议回到 Framework 3.5(如果您不使用 4.5 功能)来争取一些时间来编写新控件