posts - 315, comments - 268, trackbacks - 15

My Links

News

View Pietro Libro's profile on LinkedIn

DomusDotNet
   DomusDotNet

Pietro Libro

Tag Cloud

Article Categories

Archives

Post Categories

Blogs amici

Links

FTP: lista delle directory e dei file remoti

Come ottenere la lista delle directory e dei file remoti
utilizzando gli oggetti FtpWebRequest e FtpWebResponse

System.Net.FtpWebRequest conn =null ;
System.Net.FtpWebResponse resp = null;
conn = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://localhost"));
conn.Credentials = new NetworkCredential("username", "password");
conn.KeepAlive = false;
conn.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
 
//Ottiene la risposta
resp = (FtpWebResponse)(conn.GetResponse());
StreamReader strReader = new StreamReader(resp.GetResponseStream(), System.Text.ASCIIEncoding.ASCII);
//ArrItems contiene la lista di files e directory
string strItems = strReader.ReadToEnd();
string[] arrItems = strItems.Split("\n".ToCharArray());
strReader.Close();


Print | posted on sabato 6 ottobre 2007 06:31 | Filed Under [ Varie ed eventuali C# ]

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET