WebClient

  • Thread starter Thread starter Arash
  • Start date Start date
A

Arash

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());

}
 
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,

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.
 
Back
Top