FtpWebRequest

G

Guest

Can you find anything wrong with the code below? It blows up in io =
request.GetRequestStream.
It worked fine with one FTP server and not with another.

Dim request As FtpWebRequest
Dim password As String
Dim response As FtpWebResponse
password = ConfigurationManager.AppSettings("ftppwd")
request = WebRequest.Create(FTPlocation.Text)
request.Method = WebRequestMethods.Ftp.UploadFile
request.Credentials = New NetworkCredential(FTPAccount.Text,
password)
Dim io As Stream
buff = out.ToString
Dim b As Byte()
b = Encoding.ASCII.GetBytes(buff)
request.ContentLength = b.Length
io = request.GetRequestStream
io.Write(b, 0, b.Length)
io.Close()
 
V

Vadym Stetsyak

It will be greatly helpful if you will tell the exception message that is
thrown
 
G

Guest

System.Net.WebException: The remote server returned an error: 227 Entering
Passive Mode (209,98,235,43,4,4) . ---> System.Net.Sockets.SocketException: A
connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond at
 
V

Vadym Stetsyak

Hmm, it seems that remote server didn't allow you to connect to it. There
can be a lot of reasons why remote server refused connection.

To get more details about this situation it will be a good idea to enable
network tracing and see what network I/O is happening.

See, the details at

( http://msdn2.microsoft.com/a6sbz1dx.aspx )
 
G

Guest

Vadym,
I can connect fine with a program called LeechFTP. I can't connect with a
program. I can't connect with a response file and command line ftp.
 
V

Vadym Stetsyak

That is why I've recommended you to use network tracing functionality.
It can be configured so that you can log all the traffic between your app
and
remote FTP server. Having this info you can determine the reason (analyze
traffic log), why FTP server
refuses connection.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top