Hey
I am searching a dir for keywords and when it finds a file it adds it to a list box. here is the code
VB Code:
Dim TheDir As String = txtDir.Text Dim di As New IO.DirectoryInfo(TheDir) Dim diar1 As IO.FileInfo() = di.GetFiles() Dim dra As IO.FileInfo For Each dra In diar1 Dim Filename As String = IO.Path.GetFileNameWithoutExtension(dra.FullName) If dra.Extension = ".rtf" Or dra.Name.ToLower.IndexOf(txtSong.Text.ToLower) > -1 Then results.Items.Add(dra) End If Next
that works and it adds them to a list box my problem it that i want to use the data in the listbox as a string and don't know how to convert it.
if i try to go messagebox.show (results.SelectedItem) i get the error : Cast from type 'FileInfo' to type 'String' is not valid.
If anyone knows how to conver the listbox to a sting that would be great thanks alot




Reply With Quote