A
Alan Gillott
I have the following code (stolen from VB2005 with Net 3.0)
I've tried to get help here before but I think I need somewhere with a
better understanding of FTP with .Net but I can't for the life of me find a
more applicable forum. Can anyone direct me accordingly?:
Private Function DoFTPRequest(ByVal url As String, ByVal method As String,
ByVal usebinary As Boolean, ByRef data As stream) As FtpStatusCode
'Imports System.Net These are just comments to remind me what to
import if I copy this routine elsewhere
'Imports System.IO
Dim result As FtpStatusCode
Dim req As FtpWebRequest
Dim resp As FtpWebResponse
Dim creds As New NetworkCredential("anonymous", "(e-mail address removed)")
creds.UserName = "anonymous" 'For testing
creds.Password = "(e-mail address removed)"
req = DirectCast(WebRequest.Create(url), FtpWebRequest)
With req
''''''.Credentials = creds
.UseBinary = usebinary
.UsePassive = True
.KeepAlive = True
'.Method = method
.Method = "LIST"
resp = .GetResponse() <=== This gives me
FTPStatuscode.dataAlreadyOpen (125)
'Pathetic attempt to see if it goes away...
Do While resp.StatusCode = FtpStatusCode.DataAlreadyOpen
System.Threading.Thread.Sleep(1000)
resp = .GetResponse()
Loop
data = resp.GetResponseStream
result = resp.StatusCode
End With
Return result
End Function
I've tried to get help here before but I think I need somewhere with a
better understanding of FTP with .Net but I can't for the life of me find a
more applicable forum. Can anyone direct me accordingly?:
Private Function DoFTPRequest(ByVal url As String, ByVal method As String,
ByVal usebinary As Boolean, ByRef data As stream) As FtpStatusCode
'Imports System.Net These are just comments to remind me what to
import if I copy this routine elsewhere
'Imports System.IO
Dim result As FtpStatusCode
Dim req As FtpWebRequest
Dim resp As FtpWebResponse
Dim creds As New NetworkCredential("anonymous", "(e-mail address removed)")
creds.UserName = "anonymous" 'For testing
creds.Password = "(e-mail address removed)"
req = DirectCast(WebRequest.Create(url), FtpWebRequest)
With req
''''''.Credentials = creds
.UseBinary = usebinary
.UsePassive = True
.KeepAlive = True
'.Method = method
.Method = "LIST"
resp = .GetResponse() <=== This gives me
FTPStatuscode.dataAlreadyOpen (125)
'Pathetic attempt to see if it goes away...
Do While resp.StatusCode = FtpStatusCode.DataAlreadyOpen
System.Threading.Thread.Sleep(1000)
resp = .GetResponse()
Loop
data = resp.GetResponseStream
result = resp.StatusCode
End With
Return result
End Function