Problem Uploading File Using FtpWebRequest

D

daveh42

Hi,

We want to upload a file to a business partner using FTP with SSL from our
intranet. Our proof of concept solution in VB uses FtpWebRequest based on an
example at http://www.123aspx.com/redir.aspx?res=34336:

Dim reqObj As FtpWebRequest =
WebRequest.Create("ftp://ftps.example.com:1742/123456789_12-31-2007")

reqObj.EnableSsl = True
reqObj.UsePassive = True
reqObj.Method = WebRequestMethods.Ftp.UploadFile
reqObj.Credentials = New NetworkCredential("username", "password")

Dim streamObj As FileStream = File.OpenRead("D:\Files\123456789_12-31-2007")
Dim buffer(streamObj.Length) As Byte

streamObj.Read(buffer, 0, buffer.Length)
streamObj.Close()
streamObj = Nothing

Dim reqStream As Stream

reqStream = reqObj.GetRequestStream()
reqStream.Write(buffer, 0, buffer.Length)
reqStream.Close()
reqStream = Nothing
reqObj = Nothing

We are getting the error "Unable to connect to the remote server" on the
"reqStream = reqObj.GetRequestStream()" line. The username and password are
correct. What should we check next?


Thanks,

Dave
 
S

Scott Roberts

daveh42 said:
Hi,

We want to upload a file to a business partner using FTP with SSL from our
intranet. Our proof of concept solution in VB uses FtpWebRequest based on
an
example at http://www.123aspx.com/redir.aspx?res=34336:

Dim reqObj As FtpWebRequest =
WebRequest.Create("ftp://ftps.example.com:1742/123456789_12-31-2007")

reqObj.EnableSsl = True
reqObj.UsePassive = True
reqObj.Method = WebRequestMethods.Ftp.UploadFile
reqObj.Credentials = New NetworkCredential("username", "password")

Dim streamObj As FileStream =
File.OpenRead("D:\Files\123456789_12-31-2007")
Dim buffer(streamObj.Length) As Byte

streamObj.Read(buffer, 0, buffer.Length)
streamObj.Close()
streamObj = Nothing

Dim reqStream As Stream

reqStream = reqObj.GetRequestStream()
reqStream.Write(buffer, 0, buffer.Length)
reqStream.Close()
reqStream = Nothing
reqObj = Nothing

We are getting the error "Unable to connect to the remote server" on the
"reqStream = reqObj.GetRequestStream()" line. The username and password
are
correct. What should we check next?

Firewall settings.

Can you connect to the remote server using a commercial FTP client? If so,
are you connecting with the same settings (SSL, Passive, etc.)?
 

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

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top