Click here to Skip to main content
15,915,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello friends,

I am trying to upload file through my locals to a Web Server but I am not able to save it on the Web Server. I have given all the necessary credentials required for the same but still time an again i get an error as: The remote server returned an error: (404) Not Found..

I am not able to sort out where I am going wrong as from many of the articles I have read that it requires just two to three lines of code to perform the same.

Please find the code below:

try
{
  WebClient client = new WebClient();

  string myFile = fileInfo.FullName;                

  string newAttachPath = fileStoragePath + myFile;

//client.Credentials = CredentialCache.DefaultCredentials;   
             
  NetworkCredential netwrkCreden = new    networkCredential("username","password","domain");

  client.Credentials = netwrkCreden;

  client.UploadFile(newAttachPath, "PUT",myFile);  
  
  client.Dispose();
}
catch(Exception ex)
{
  MessageBox.Show(ex.Message);
}



Thanks

Varun Sareen
Posted
Comments
Ankur\m/ 24-Sep-10 1:41am    
404 means the resource could not be found. Can you confirm if the path you are saving the file is correct?
Hiren solanki 24-Sep-10 1:43am    
ankur I think this may be problem again of fulllocation + fulllocationwith file name (404) Hope you will be agree this time.
Ankur\m/ 24-Sep-10 1:45am    
I will wait to hear from OP. :)

1 solution

ask ur service provider to provide access rights to the folder where u r storing the file coz by default tey dont allow write facility
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900