A byte array containing the body of the response from the resource.
Type Reason 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".
System.Security.SecurityException Local file access has not been granted.
The WebClient.UploadFile(string, string) method sends a local file to a resource. This method uses the STOR command to upload an FTP resource. For an HTTP resource, the POST method is used.
This method blocks while uploading the file. To continue executing while waiting for the server's response, use one of the erload:System.Net.WebClient.UploadFileAsync methods.
The POST method is defined by HTTP. If the underlying request does not use HTTP and POST is not understood 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.
If the WebClient.BaseAddress property is not an empty string ("") and address does not contain an absolute URI, address must be a relative URI that is combined with WebClient.BaseAddress to form the absolute URI of the requested data. If the WebClient.QueryString property is not an empty string, it is appended to address.
This member outputs trace information when you enable network tracing in your application. For more information, see Network Tracing.
Type | Reason |
---|---|
System.Security.Permissions.FileIOPermission | Requires permission to access path information and read files. See System.Security.Permissions.FileIOPermissionAccess.PathDiscovery and System.Security.Permissions.FileIOPermissionAccess.Read. |