473,326 Members | 2,815 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,326 software developers and data experts.

WebClient

Hi everybody,
I am trying to upload a file to my local server (http://mymachine) using
the code below, what I get as error is:
"... ---> System.ArgumentException: URI formats are not supported. ..."
I have also tryed the destination without file name (ommiting "Cop.jpg") and
got the same error. Please please help me.

Regards
Arash
Code:

private void btnUpload_Click(object sender, System.EventArgs e)

{

WebClient mClient = new WebClient();

try{

mClient.UploadFile("D:\\Cop.jpg"," http://mymachine/Pars/Images/Cop.jpg ");

}catch(Exception el){

MessageBox.Show("Excep "+ el.ToString());

}
Nov 15 '05 #1
2 3616
have you tried using a remote url that is a web form that can handle the raw
request data and save it? I don't know if that works, it's a guess.

Additionally, in case what you're doing is the right way, have you
definitely got write access to the directory in question?

"Arash" <ar*************@hotmail.com> wrote in message
news:uJ*************@TK2MSFTNGP09.phx.gbl...
Hi everybody,
I am trying to upload a file to my local server (http://mymachine) using the code below, what I get as error is:
"... ---> System.ArgumentException: URI formats are not supported. ...." I have also tryed the destination without file name (ommiting "Cop.jpg") and got the same error. Please please help me.

Regards
Arash
Code:

private void btnUpload_Click(object sender, System.EventArgs e)

{

WebClient mClient = new WebClient();

try{

mClient.UploadFile("D:\\Cop.jpg"," http://mymachine/Pars/Images/Cop.jpg ");
}catch(Exception el){

MessageBox.Show("Excep "+ el.ToString());

}

Nov 15 '05 #2
Arash,

First, are you sure that your machine has support for accepting the
file? You might want to use the overload that takes a parameter indicating
which method to use, as it will allow you to specify "PUT" (which is what I
believe you want based on the syntax you displayed).

Finally, check the BaseAddress property of the WebClient. The address
string that you pass into the method (for address parameter) is relative to
this address.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Arash" <ar*************@hotmail.com> wrote in message
news:uJ*************@TK2MSFTNGP09.phx.gbl...
Hi everybody,
I am trying to upload a file to my local server (http://mymachine) using the code below, what I get as error is:
"... ---> System.ArgumentException: URI formats are not supported. ...." I have also tryed the destination without file name (ommiting "Cop.jpg") and got the same error. Please please help me.

Regards
Arash
Code:

private void btnUpload_Click(object sender, System.EventArgs e)

{

WebClient mClient = new WebClient();

try{

mClient.UploadFile("D:\\Cop.jpg"," http://mymachine/Pars/Images/Cop.jpg ");
}catch(Exception el){

MessageBox.Show("Excep "+ el.ToString());

}

Nov 15 '05 #3

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

Similar topics

11
by: ptass | last post by:
Hi I've installed win2k3 sp1 on a machine where an openRead on any given file was previously working. After installation, I get a webException as follows... ..message "An exception occurred...
3
by: Ram Baruch | last post by:
Hi, I'm trying to use WebClient class to upload data. In order to upload it, I need to use my username and password. Does somebody know how can I set it in the WebClient class? Regards, Ram.
2
by: xzzy | last post by:
I have .net 1.1 c# . . . . . using System.Net only lists sockets what do I need to do to be able to do: using System.Net.WebClient;
6
by: A.M-SG | last post by:
Hi, I have an aspx page at the web server that provides PDF documents for smart client applications. Here is the code in aspx page that defines content type: Response.ContentType =...
6
by: Giovanni | last post by:
Hi Guys, Really strange problem I am experiencing... I have setup a virtual directory with Read Only permissions on an ISA/IIS server (SBS 2003). In that virt. dir., I placed 1 file...
1
by: vin.dor | last post by:
Dear All, I am using WebClient in my Visual Studio .Net 2003 project to download an image from the Internet. The following is my function: C# Code: public static bool downloadFile(string...
4
by: Lehel Kovach | last post by:
I'm having a problem with the WebClient object. When I post data to certain sites, it will receive a command from the webserver (object moved) and continue to the next link by downloading that. ...
1
by: Mad Scientist Jr | last post by:
For some reason I can't get a WebClient to access an outside URL from behind our firewall. The code works when it runs outside the firewall. I turned on windows authentication in the web.config...
1
by: Mike | last post by:
I am using PowerShell to download an XML file into a string using the DownloadString(URI) method of System.Net.WebClient object. Sample commands below: $Result = $Null; $WebClient = new-object...
2
by: MichaelSchoeler | last post by:
Hi, I'm having problems with the WebClient class regarding UTF-8 encoded data. When I access a specific webservice directly I can see the data arrives in corretly formatted UTF-8. But when I...
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
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.