Question Using ListBox to display files from FTP site

Dan181920

Active member
Joined
Jun 28, 2011
Messages
27
Programming Experience
Beginner
Hello,

I am trying to program my page in ASP.Net and VB.Net so that when the page loads, a list of files from my FTP site appear on the screen.

I am also trying to get it so that a user can select one of the files and download it to their computer.

I have been advised to use ListBox using System.Web.UI.WebControls

Can anybody advise on how I would use this to grab the file list from the FTP site?

Thank you in advance.

Dan
 
You wouldn't use it to grab the list of files from the FTP site. A ListBox is used to display a list of items and that's it. It doesn't really care what the items are or where they came from. You need to use whatever method is appropriate to get the list of files first, then you can display that list in the ListBox.

To get the list, you have two options:

1. If the web server and the FTP server are on the same machine then you can, if appropriate, simply use regular file system access to get the file list, i.e. Directory.GetFiles or DirectoryInfo.GetFiles.
2. If that's not appropriate or possible then you will have to do what everyone else does: use an FtpWebRequest with the Method set to ListDirectory or ListDirectoryDetails.
 
Back
Top