lucausa75
18-12-2010, 13:07
Salve ragazzi,
come ben sapete sono ormai passato da tempo a VB Net e sto avendo qualche problema nella creazione di questa Function:
Public Function CheckIfFtpFileContains(ByVal path As String, ByVal SearchStr As String) As Boolean
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
_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
CheckIfFtpFileContains = IIf(InStr(str, SearchStr) > 0, True, False)
If CheckIfFtpFileContains = True Then
MessageBox.Show("Trovato")
Exit While
End If
End If
str = sr.ReadLine()
End While
sr.Close()
sr.Dispose()
sr = Nothing
_FtpRequest = Nothing
'Return XXXXXXXXXXXXXXXXXXXXXXXXXXXX
End Function
che mi restituisce il seguente avviso:
http://img585.imageshack.us/img585/9572/18122010140504.th.png (http://img585.imageshack.us/i/18122010140504.png/)
Come risolvo?
Grazie
come ben sapete sono ormai passato da tempo a VB Net e sto avendo qualche problema nella creazione di questa Function:
Public Function CheckIfFtpFileContains(ByVal path As String, ByVal SearchStr As String) As Boolean
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
_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
CheckIfFtpFileContains = IIf(InStr(str, SearchStr) > 0, True, False)
If CheckIfFtpFileContains = True Then
MessageBox.Show("Trovato")
Exit While
End If
End If
str = sr.ReadLine()
End While
sr.Close()
sr.Dispose()
sr = Nothing
_FtpRequest = Nothing
'Return XXXXXXXXXXXXXXXXXXXXXXXXXXXX
End Function
che mi restituisce il seguente avviso:
http://img585.imageshack.us/img585/9572/18122010140504.th.png (http://img585.imageshack.us/i/18122010140504.png/)
Come risolvo?
Grazie