4

I have a VB6 application that has been migrated to VB.net, and am trying to upgrade the framework version to 4.5 -- which complained that everything in Microsoft.VisualBasic.Compatibility dll was obsolete. I was able to replace everything except the FileListBox and DirListBox fairly easily -- tedious but I didn't have to create any new controls.

Is there a close replacement for these controls? Does anyone know if they have been opened sourced with the rest of the framework?

jmoreno
  • 12,752
  • 4
  • 60
  • 91

2 Answers2

5

You can use simple ListBox control and use My.Computer.FileSystem to make them as old DriveListBox, DirectoryListBox and FileListBox. You can use something like following

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

All the lst are just normal ListBoxes you can also use ListView control, similar way.

KMan
  • 155
  • 1
  • 9
0

Unfortunately you will have to roll your own (just like @kman has kicked you off).

Some alternatives have been discussed here : https://social.msdn.microsoft.com/Forums/en-US/b2d13c9a-e320-4f36-981e-e4c1999d7694/vbnet-equivalent-of-vb6-code-which-are-obsolete?forum=vbinterop

Someone suggest going back to Framework 3.5 (if you are not using 4.5 features) to buy some time to write new controls

joehanna
  • 1,471
  • 1
  • 11
  • 22