Uploading files to server
- by Shivkumar
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?