C# WebClient UploadValues(String, NameValueCollection)

Description

WebClient UploadValues(String, NameValueCollection) Uploads the specified name/value collection to the resource identified by the specified URI.

Syntax

WebClient.UploadValues(String, NameValueCollection) has the following syntax.


public byte[] UploadValues(
  string address,
  NameValueCollection data
)

Parameters

WebClient.UploadValues(String, NameValueCollection) has the following parameters.

  • address - The URI of the resource to receive the collection.
  • data - The NameValueCollection to send to the resource.

Returns

WebClient.UploadValues(String, NameValueCollection) method returns

Example


using System;//www  . j  a  v a  2s.c o m
using System.Net;
using System.Net.Sockets;
using System.Collections.Specialized;
using System.Text;

public class Example
{
    public static void Main()
    {
        string uriString = "http://your server";
        WebClient myWebClient = new WebClient();
        NameValueCollection myNameValueCollection = new NameValueCollection();
        string name = "HTML";
        string age = "23";
        string address = "W3C";
        myNameValueCollection.Add("Name", name);
        myNameValueCollection.Add("Address", address);
        myNameValueCollection.Add("Age", age);
        byte[] responseArray = myWebClient.UploadValues(uriString, myNameValueCollection);
        Console.WriteLine("\nResponse received was :\n{0}", Encoding.ASCII.GetString(responseArray));


    }
}




















Home »
  C# Tutorial »
    System.Net »




Cookie
Dns
IPAddress
IPEndPoint
IPHostEntry
WebClient