Upload the specified local file to the specified resource, using the specified method in CSharp

Description

The following code shows how to upload the specified local file to the specified resource, using the specified method.

Example


using System;/* www  .  j a  v a 2s  .  co  m*/
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(uriString,"POST",fileName);
            Console.WriteLine("\nResponse Received.The contents of the file uploaded are:\n{0}",
            System.Text.Encoding.ASCII.GetString(responseArray));
   }
}




















Home »
  C# Tutorial »
    Network »




IP
Web Client