Upload the specified local file to a resource with the specified URI in CSharp
Description
The following code shows how to upload the specified local file to a resource with the specified URI.
Example
//from w w w . j a v a2 s . co m
using System;
using System.Net;
using System.Net.Sockets;
public class Example
{
public static void Main()
{
String uriString = "http://your Server";
WebClient myWebClient = new WebClient();
string fileName = "index.htm";
byte[] responseArray = myWebClient.UploadFile(new Uri(uriString),fileName);
Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}",
System.Text.Encoding.ASCII.GetString(responseArray));
}
}