p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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.

 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 11th, 2005, 11:07 AM
mh mh is offline
Authorized User
Points: 231, Level: 4
Points: 231, Level: 4 Points: 231, Level: 4 Points: 231, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #2 (permalink)  
Old April 12th, 2005, 12:59 PM
mh mh is offline
Authorized User
Points: 231, Level: 4
Points: 231, Level: 4 Points: 231, Level: 4 Points: 231, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #3 (permalink)  
Old April 13th, 2005, 09:26 PM
planoie's Avatar
Friend of Wrox
Points: 16,368, Level: 55
Points: 16,368, Level: 55 Points: 16,368, Level: 55 Points: 16,368, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
Default

Are you saying you want to actually FTP?

System.IO is for your local system, not a remote FTP location.

-Peter
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #4 (permalink)  
Old April 14th, 2005, 09:50 AM
mh mh is offline
Authorized User
Points: 231, Level: 4
Points: 231, Level: 4 Points: 231, Level: 4 Points: 231, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #5 (permalink)  
Old April 14th, 2005, 01:53 PM
planoie's Avatar
Friend of Wrox
Points: 16,368, Level: 55
Points: 16,368, Level: 55 Points: 16,368, Level: 55 Points: 16,368, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,394
Thanks: 0
Thanked 2 Times in 2 Posts
Default

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #6 (permalink)  
Old April 15th, 2005, 01:51 AM
Friend of Wrox
Points: 1,351, Level: 14
Points: 1,351, Level: 14 Points: 1,351, Level: 14 Points: 1,351, Level: 14
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ftp client library for C#
http://www.codeproject.com/csharp/ftplibrary.asp
google.

_____________
Mehdi.
software student.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
  #7 (permalink)  
Old April 15th, 2005, 11:43 AM
mh mh is offline
Authorized User
Points: 231, Level: 4
Points: 231, Level: 4 Points: 231, Level: 4 Points: 231, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2005
Location: , , .
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for everyone's help. :)

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP to list files in a directory dynamically melkin Classic ASP Professional 10 August 1st, 2007 07:25 PM
Directory.GetFiles got other not related files cmyeung_99 C# 2005 0 June 29th, 2006 10:16 PM
How do I read all the xml files in a directory hkec C# 0 May 11th, 2006 02:10 AM
View Files in a Directory echovue Access 1 October 15th, 2005 03:36 PM
displaying files in a listbox mh Classic ASP Basics 2 April 11th, 2005 10:55 AM



All times are GMT -4. The time now is 11:05 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc