nondrinker
Programmer
Hello,
I have been trying to display the contents of a folder in a list box but so far i am having some problems. The closest i have come to is display the file name in a multiline textbox using this code.
***********************************
Dim varFolderPath As String
varFolderPath = "\\[My folder path here]"
Dim objFile As FileInfo
Dim objDir As DirectoryInfo
Dim t As String
t = ""
For Each objFile In objDir.GetFiles("*.*")
Try
txtFiles.Text = objFile.Name.ToString
If t <> "" Then
t = t & ";"
End If
t = objFile.Name.ToString
txtFiles.Text = t
Catch ex As Exception
MsgBox("Error in displaying files")
End Try
Next
************************************
But what this code does is just display the name of the last file in the folder instead of all the files. But eventually i would like to use a listbox, instead of a text box to display the names of all files in the folder.
I am using MS VisualStudio .NET 2003.
Any help will be appreciated.
Thanu you.
I have been trying to display the contents of a folder in a list box but so far i am having some problems. The closest i have come to is display the file name in a multiline textbox using this code.
***********************************
Dim varFolderPath As String
varFolderPath = "\\[My folder path here]"
Dim objFile As FileInfo
Dim objDir As DirectoryInfo
Dim t As String
t = ""
For Each objFile In objDir.GetFiles("*.*")
Try
txtFiles.Text = objFile.Name.ToString
If t <> "" Then
t = t & ";"
End If
t = objFile.Name.ToString
txtFiles.Text = t
Catch ex As Exception
MsgBox("Error in displaying files")
End Try
Next
************************************
But what this code does is just display the name of the last file in the folder instead of all the files. But eventually i would like to use a listbox, instead of a text box to display the names of all files in the folder.
I am using MS VisualStudio .NET 2003.
Any help will be appreciated.
Thanu you.