473,832 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error uploading e file with FtpWebRequest

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 from the Internet Explorer so I have rights to do
it. Why is the 2.0 FtpWebRequest class failing? What I am doing wrong?

My Code:
Dim ftpUri As Uri
Dim s As String

Dim oStream As New StreamReader(ms trFileName)
Dim arBytes() As Byte = Encoding.UTF8.G etBytes(oStream .ReadToEnd())
oStream.Close()

ftpUri = New Uri(mstrRemoteH ost)

If Not (ftpUri.Scheme = Uri.UriSchemeFt p) Then
Throw New ArgumentExcepti on("URI is not an FTp site")
End If

Dim ftpRequest As FtpWebRequest = CType(WebReques t.Create(ftpUri ),
FtpWebRequest)

ftpRequest.Meth od = WebRequestMetho ds.Ftp.UploadFi le

ftpRequest.Cont entLength = arBytes.Length

ftpRequest.Cred entials = New NetworkCredenti al(mstrRemoteUs er,
mstrRemotePassw ord)

Dim oftpStream As Stream

Try
oftpStream = ftpRequest.GetR equestStream()
Catch ex As Exception
Return ex.Message
End Try

oftpStream.Writ e(arBytes, 0, arBytes.Length)
oftpStream.Clos e()

Dim ftpResponse As FtpWebResponse
ftpResponse = ftpRequest.GetR esponse

s = ftpResponse.Sta tusDescription

Return s
Feb 21 '06 #1
0 2775

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

Similar topics

1
1470
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 FTP client as well as windows explorer, the domain\username and password are also valid auths. I've also downloaded two seperate classes similiar to the code below, from MSDN, and I'm getting this same error message whatever I do. Any
0
9811
by: Buddy Home | last post by:
Hello, I'm trying to upload a file programatically and occasionally I get the following error message. Unable to write data to the transport connection: An established connection was aborted by the software in your host machine. Stack Trace at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
5
7696
by: Sendil kumar | last post by:
Hi All, The FtpWebRequest.GetResponse( ) method is not giving "550 File not found exception " when I do a directory list operation on a invalid(not present) directory in HP Unix and Sun Solaris system, but the same is working fine in windows. For example, this is my uri to connect to the Sun Solaris server machine "ftp://ssriniva:ssriniva@apfsun/apfqa/users/ssriniva/apfhome/config" here the 'config' folder is not present in the...
2
2221
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 every succeessful upload. But its working well for the file which has small size around 1MB. Please give me a solution asap... My code is as follows. string ftpServerIP = rowClient.ToString(); string ftpUserID =...
3
2618
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 every succeessful upload. But its working well for the file which has small size around 1MB. Please give me a solution asap... My code is as follows. string ftpServerIP = rowClient.ToString(); string ftpUserID = rowClient.ToString(); ...
0
969
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 uploaded. I have used the following code to upload the file. -------------------------------------------------------------------------- public void UploadData(string FTPUri, string FilePath, string FileName, string UserName, string Password) {...
0
1299
by: jason7069 | last post by:
Hi There. I recently implemented a FTP upload feature within an ASP.NET application. I use the standard steps that are posted throughout the web. The basic funcationality works as a file is created on the FTP server that is the identical size to what I am uploaded. However, if the file is a non-text format (JPG, XLS) the resulting file that is posted to FTP is not a valid file type. For example, I uploaded a JPG and
5
7920
by: TC | last post by:
Hey All, I'm trying to upload files via FTP and I'm using FtpWebRequest and WebClient. Unfortunately, I'm receiving a "Not Logged In" error. I know that others have seen this as I've seen postings but I haven't seen any clear resolution.
0
1344
by: =?Utf-8?B?Qm9i?= | last post by:
I have written a Windows service that periodically lists the contents of an FTP directory until a new file becomes available. Then, it gets the new file and writes it to the local server. Most of the time, this works fine, but occasionally I get the following exception while getting the directory listing: Message: The underlying connection was closed: An unexpected error occurred on a receive. Source: System, Void...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10781
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5624
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5789
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4421
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3972
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3078
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.