Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.1
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2005, 10:07 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
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

 
Old April 12th, 2005, 11:59 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
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.

 
Old April 13th, 2005, 08:26 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Are you saying you want to actually FTP?

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

-Peter
 
Old April 14th, 2005, 08:50 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
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.

 
Old April 14th, 2005, 12:53 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 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.
 
Old April 15th, 2005, 12:51 AM
Friend of Wrox
 
Join Date: Jul 2004
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.
 
Old April 15th, 2005, 10:43 AM
mh mh is offline
Authorized User
 
Join Date: Mar 2005
Posts: 66
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for everyone's help. :)






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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.