|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Jun 2001
Città: Catania
Messaggi: 2690
|
[VB2010] - Lista file da FTP
Salve ragazzi,
la routine a sueguire funziona alla perfezione: Codice:
Public Function GetFileList(ByVal path As String, ByVal MyList As ListBox) As List(Of String)
Dim retList = New List(Of String)
If (path = Nothing Or path = "") Then
path = "/"
End If
_FtpRequest = CType(WebRequest.Create("ftp://" + _Host + path), FtpWebRequest)
_FtpRequest.Credentials = New NetworkCredential(_UserName, _Password)
_FtpRequest.UsePassive = False 'Is necessary to set the ftp request in passive mode in order to avoid error 227
_FtpRequest.UsePassive = True 'Is necessary to set the ftp request in passive mode in order to avoid error 425
_FtpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails
_FtpRequest.EnableSsl = _UseSSL
_FtpRequest.Proxy = Nothing
_FtpResponse = CType(_FtpRequest.GetResponse(), FtpWebResponse)
Dim sr As New IO.StreamReader(_FtpRequest.GetResponse().GetResponseStream())
Dim str As String = sr.ReadLine()
While Not str Is Nothing
If Not str.StartsWith(".") Then
MyList.Items.Add(str)
End If
str = sr.ReadLine()
End While
sr.Close()
sr.Dispose()
sr = Nothing
_FtpRequest = Nothing
Return retList
End Function
FALSE==>Per evitare l'errore 227 TRUE==>Per evitare l'errore 425 Mi servirebbe capire come impostare automaticamente questa proprietà in modo da adattarsi all'"uso" Grazie
__________________
Unisciti a noi: http://www.swproduction.altervista.org/ - http://www.enews.altervista.org/
|
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 05:25.



















