473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem Uploading File Using FtpWebRequest

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

Dec 18 '07 #1
1 1872

"daveh42" <da*****@discussions.microsoft.comwrote in message
news:4F**********************************@microsof t.com...
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.)?

Dec 18 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: SevDer | last post by:
Hi, I am trying to write a simple application which copies the predefined files (hardcoded in the code) to my ftp server. I couldn't make it working. I don't want to use any 3rd party...
0
by: Alexis | last post by:
Hello, I am trying to upload a file to an ftp server using the FtpWebRequest class, but I get the following error. The requested URI is invalid for this FTP command. I do can upload the file...
1
by: dawson | last post by:
Hello, when running the code below, it returns the error message: "The requested URI is invalid for this FTP command.". I have confirmed the FTP URI is correct and working through a standalone...
2
by: pritesh3173 | last post by:
I am working on windows application with c#.net . I am using FTPwebreuqest class for upload file on ftp.it works fine when there is no proxy between application and internet. but it doesn't work in...
2
by: Bremanand | last post by:
Hi folks, i am working in C# , i have problem while uploading the file to FTP which has size around 4MB. The code which comes after the bold area is not executed.. here am...
3
by: Bremanand | last post by:
Hi folks, i am working in C# , i have problem while uploading the file to FTP which has size around 4MB. The code which comes after the bold area is not executed.. here am interacting with DB for...
0
by: pavya | last post by:
Hi All, I am working on FTP uitility using C#. I have build a class for that using C#. But while uploading the file on FTP i am unable to upload whole file on the FTP. Only part of that file is...
0
by: libish | last post by:
hi all, i'm trying to develop a file uploader, it uses ftp, language is c# the application is c#windows app the main part of code that i use is as below try { FtpWebRequest...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.