Network.UploadFile Method (String, String, String, String, Boolean, Int32, UICancelOption)
Sends the specified file to the specified host address.
Assembly: Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
public void UploadFile( string sourceFileName, string address, string userName, string password, bool showUI, int connectionTimeout, UICancelOption onUserCancel )
Parameters
- sourceFileName
- Type: System.String
Path and name of file to upload.
- address
- Type: System.String
URL, IP address, or URI of destination server.
- userName
- Type: System.String
User name to authenticate. Default is an empty string: "".
- password
- Type: System.String
Password to authenticate. Default is an empty string: "".
- showUI
- Type: System.Boolean
Whether to display progress of the operation. Default is False.
- connectionTimeout
- Type: System.Int32
Timeout interval in milliseconds. Default is 100 seconds.
- onUserCancel
- Type: Microsoft.VisualBasic.FileIO.UICancelOption
Action to be taken when the user clicks Cancel. Default is ThrowException.
| Exception | Condition |
|---|---|
| ArgumentException |
The source file path is not valid. |
| ArgumentException |
connectionTimeout is less than or equal to zero. |
| InvalidOperationException |
address does not include a file name. |
| SecurityException |
Authentication failed. |
| TimeoutException |
The server does not respond within the specified connectionTimeout. |
| SecurityException |
The user authentication fails. |
| SecurityException |
User lacks necessary permissions to perform a network operation. |
| WebException |
The request is denied by the target web server. |
If showUI is set to True, a dialog box shows the progress of the operation and includes a Cancel button that the user can click to cancel the operation. Because the dialog box is not modal, it does not block user input to other windows in the program.
If the server does not respond within the interval specified in connectionTimeout, the operation is cancelled and an exception is thrown.
My.Computer.Network.UploadFile outputs trace information when you enable network tracing in your application. For more information, see Enabling Network Tracing.
Note
|
|---|
|
The FTP protocol sends information, including passwords, in plain text and should not be used for transmitting sensitive information. |
The following table lists an example of a task involving the My.Computer.Network.UploadFile method.
|
To |
See |
|
Upload a file |
-
FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.
-
UIPermission
Controls the permissions related to user interfaces and the clipboard. Associated enumeration: AllWindows.
-
WebPermission
Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note