displaying files from a directory
Hello,
I've been trying to display files from a ftp directory using the system.io.file method. However, it doesn't seem to be working. What happens is that I have a dropdownlist (dlstep). When it is selected to 2, and a button (cmdexc) is clicked, it should check to see if files exist in that particular directory. If they do, then they are to display all of the filenames in a listbox which is what I have. Can someone please tell me what I'm doing wrong? I have a feeling that this statement: "TextBox1.Text = myfile.ToString" is wrong. However,I am unable to replace "tostring" with "getfile" because I get an error. Below is my code and I'm using asp.net on a web application. Thanks.
Private Sub cmdExc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdExc.Click
If dlStep.SelectedValue = "2" Then
Dim mypath As String = "ftpsite"
Dim myDirectory As System.IO.Directory
Dim files As System.IO.File
Dim myfile As String
If files.Exists(mypath) Then
For Each myfile In myDirectory.GetFiles(mypath)
ListBox1.DataTextField= myfile.ToString
Next
End If
End Sub
|