|
|
 |
| ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.1 section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|

April 11th, 2005, 11:07 AM
|
|
Authorized User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|

April 12th, 2005, 12:59 PM
|
|
Authorized User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have finally been able to display files from a directory onto my listbox from my c drive. However, when I try to display files from a ftp site, it gives me the following error:
The given path's format is not supported.
Are ftp sites not supportable in this case? Here is my code:
Private Sub cmdExc_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdExc.Click
If dlStep.SelectedValue = "2" Then
Dim myDirectory As New System.IO.DirectoryInfo("ftpsite")
Dim files As System.IO.FileInfo() = myDirectory.GetFiles()
Dim myfile As System.IO.FileInfo
If Dir("ftpsite*.*") = "" Then
TextBox1.Text = "empty"
Else
For Each myfile In files
ListBox1.Items.Add(myfile.ToString)
Next
TextBox1.Text = "not empty"
End If
Else
TextBox1.Text = "not selected"
End If
End Sub
I would really appreciate it if someone could help me. Thanks.
|

April 13th, 2005, 09:26 PM
|
 |
Friend of Wrox
Points: 16,368, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Are you saying you want to actually FTP?
System.IO is for your local system, not a remote FTP location.
- Peter
|

April 14th, 2005, 09:50 AM
|
|
Authorized User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
What I'm saying is that I want to display files from a ftp directory, not to necessarily ftp files. Is there a way to do this? Thanks.
|

April 14th, 2005, 01:53 PM
|
 |
Friend of Wrox
Points: 16,368, Level: 55 |
|
|
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
|
|
Either way, you have to talk to an FTP server. The System.IO classes aren't made for that. To my knowledge there aren't any native .NET classes that do this.
|

April 15th, 2005, 11:43 AM
|
|
Authorized User
|
|
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thank you for everyone's help. :)
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |