download a servers folder

Johnson

Well-known member
Joined
Mar 6, 2009
Messages
158
Programming Experience
Beginner
i assume i need ftp for this. I need to download a folder contents of images from my server.

any one got a tutorial?
 
Sure, CodeProject: An FTP client library for .NET 2.0. Free source code and programming help. Download the file, open the ftpClient.vs copy it to a class in your program. What you will need is to something like:
VB.NET:
Private Sub LoadFTPFiles()
    Dim ftp As New FTPClient(My.Settings.ftpSite, My.Settings.ftpUsername, My.Settings.ftpPassword)
    For Each file As String In ftp.ListDirectory(My.Settings.ftpFolder)
      ftp.Download(file, tempDirectory & "\" & file)
    Next
End Sub
Then in the last Download function change:
VB.NET:
Dim URI As String = Hostname & target
'to 
Dim URI As String = Hostname & My.Settings.ftpFolder & "\" & target
or whatever My.Setting.ftpfolder would be for you, it is the folder name. :cool:
 
By server to you mean an ftp location or are you just trying to retrieve files from a server located on your network? If its within you network you should be able to retrieve the files the same as any drive location on your computer except that security restrictions on your pc may need to be adjusted.
 
Basically here is my full intentions.

On my website(my own server) i allow images to be uploaded. Now any one can upload anything. restricting whats uploaded is pretty impossible.

So i want to make a app that gets the files(images) from my dir /home/upuser/uploads then downloads them all to a folder.

Then i can load them to my application and view them. eventurally being able to send a delete request to any bad ones
 
Everything you need is in the class. There is a delete file function. Remember to add the folder path like I mentioned. What are you specifically having trouble with? As far as the uploading thing, can you set up a sub domain for the upload - you inspect the pics, then you move the appropriate ones?
 
The link NewGuy provided will help meet your needs. Also if you want to take a look, I posted an example on a similar thread recently here. It shows how to get a list of file names from an ftp directory and download the files.
 
Back
Top