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

System.Net.WebClient.DownloadFile Method

Downloads data from the resource identified by the specified URI, and writes the data to the specified file . [Edit]

public void DownloadFile (string address, string fileName)

Parameters

address
A string that specifies the URI from which data will be downloaded. [Edit]
fileName
A string that specifies the name of the local file to which data will be written. [Edit]

Permissions

TypeReason
System.Security.Permissions.FileIOPermission [Edit] Requires permission to write to files. See System.Security.Permissions.FileIOPermissionAccess.Write.

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 downloading data.

[Edit]
System.Security.SecurityExceptionThe caller does not have permission to write to local files. [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.

This method downloads data from the absolute URI to local file, fileName . If fileName already exists, the existing file is overwritten.

[Edit]

Requirements

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