Mono Class Library: System.Net.WebClient Overview | Members

System.Net.WebClient.UploadFile Method

Uploads the specified local file using the specified protocol method to the resource identified by the specified URI . [Edit]

public byte[] UploadFile (string address, string method, string fileName)

Parameters

address
A string that specifies the URI of the resource to receive the file. [Edit]
method
A string that specifies the protocol method used to send the data to the resource identified by address . [Edit]
fileName
A string that specifies the file to send to the resource. [Edit]

Returns

A byte array containing the body of the response, if any, from the server hosting the resource. [Edit]

Permissions

TypeReason
System.Security.Permissions.FileIOPermission [Edit] Requires permission to access path information and read files. See System.Security.Permissions.FileIOPermissionAccess.PathDiscovery and System.Security.Permissions.FileIOPermissionAccess.Read.

Exceptions

TypeReason
System.Net.WebException

The absolute URI is not valid.

-or-

filename is null or string.Empty or contains invalid characters, or the specified path to the file does not exist.

-or-

An error occurred while opening the stream or uploading the file.

-or-

There was no response from the server hosting the resource.

-or-

The Content-Type header begins with "multipart".

[Edit]
System.Security.SecurityExceptionThe caller does not have the required permissions. [Edit]

Remarks

If the WebClient.BaseAddress property of the current instance is not string.Empty, address is combined with WebClient.BaseAddress to form the absolute URI of the requested data. If the WebClient.BaseAddress property of the current instance is string.Empty, address is required to be the absolute URI of the requested data. If the WebClient.QueryString property of the current instance is not string.Empty, it is appended to address.

Note:

For more information about protocol methods, see WebRequest.Method .

If method specifies a protocol method that is not recognized by the server, the underlying protocol classes determine what occurs. Typically, a System.Net.WebException is thrown with the WebException.Status property set to indicate the error.

[Edit]

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0