Aggiungere ad una ComboBox dei nomi dei file situati in un sito FTP

venerdì 07 settembre 2007 - 15.32

Viktrus Profilo | Newbie

Ciao a tutti. Sono nuovo e sono quasi alle prime armi con vb.net. Volevo sapere come potevo aggiungere ad una combobox un elenco di file che sono situati in un FTP di cui conosco sia l'User che la pass? Non so come ci si connette ad un server ftp.....

Grazie

hkproj Profilo | Newbie

Puoi utilizzare la classe FTPWebRequest, del namespace System.NET
ed ecco un esempio di come avere il contenuto di una directory FTP usando la classe System.NET.WebClient
public static bool DisplayFileFromServer(Uri serverUri) { // The serverUri parameter should start with the ftp:// scheme. if (serverUri.Scheme != Uri.UriSchemeFtp) { return false; } // Get the object used to communicate with the server. WebClient request = new WebClient(); // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com"); try { byte [] newFileData = request.DownloadData (serverUri.ToString()); string fileString = System.Text.Encoding.UTF8.GetString(newFileData); Console.WriteLine(fileString); } catch (WebException e) { Console.WriteLine(e.ToString()); } return true; }

Ciao!
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2025
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5