Uploading files to server

Posted by Shivkumar on Stack Overflow See other posts from Stack Overflow or by Shivkumar
Published on 2009-03-24T07:36:23Z Indexed on 2010/03/15 11:09 UTC
Read the original article Hit count: 240

Filed under:
|
|
|

I am trying to upload a file from my Windows application to the server into a particular Folder using C#. However, I am getting an exception:

"An exception occurred during a WebClient request".

Here is my code:

for (int i = 0; i < dtResponseAttach.Rows.Count; i++)
{
  string filePath = dtResponseAttach.Rows[i]["Response"];

  WebClient client = new WebClient();
  NetworkCredential nc = new NetworkCredential();

  Uri addy = new Uri("http://192.168.1.4/people/Attachments/");
  client.Credentials = nc;
  byte[] arrReturn = client.UploadFile(addy, filePath);
  Console.WriteLine(arrReturn.ToString());
}

What could be the reason for this exception?

© Stack Overflow or respective owner

Related posts about c#

Related posts about file-upload