Code:' make a reference to a directory Dim di As New IO.DirectoryInfo("c:\program files\jp\news\data\") Dim diar1 As IO.FileInfo() = di.GetFiles("*.newspaper") Dim dra As IO.FileInfo 'list the names of all files in the specified directory For Each dra In diar1 ListBox1.Items.Add(dra) Next
Code:Private Sub ListBox1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick Dim filename As String = ListBox1.SelectedItem ' this dos not work End Sub
When I dubble click listbox1 then I get this error:
***************************************************
An unhandled exception of type 'System.InvalidCastException' occurred in microsoft.visualbasic.dll
Additional information: Cast from type 'FileInfo' to type 'String' is not valid.
***************************************************
I need to be able to add the selected text into a FileOpen command:
I there another way I can do this?Code:FileOpen(1, "C:/program files/jp/news/data/" & filename, OpenMode.Input)




Reply With Quote