Network.UploadFile Network.UploadFile Network.UploadFile Network.UploadFile Method

Definition

Sends the specified file to the specified host address.

Overloads

UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

UploadFile(String, String) UploadFile(String, String) UploadFile(String, String) UploadFile(String, String)

Sends the specified file to the specified host address.

UploadFile(String, Uri) UploadFile(String, Uri) UploadFile(String, Uri) UploadFile(String, Uri)

Sends the specified file to the specified host address.

UploadFile(String, String, String, String) UploadFile(String, String, String, String) UploadFile(String, String, String, String) UploadFile(String, String, String, String)

Sends the specified file to the specified host address.

UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String)

Sends the specified file to the specified host address.

UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32)

Sends the specified file to the specified host address.

UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32)

Sends the specified file to the specified host address.

UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32)

Sends the specified file to the specified host address.

UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption) UploadFile(String, String, String, String, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, System::String ^ address, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void UploadFile (string sourceFileName, string address, string userName, string password, bool showUI, int connectionTimeout, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.UploadFile : string * string * string * string * bool * int * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub UploadFile (sourceFileName As String, address As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, onUserCancel As UICancelOption)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
String String String String

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

showUI
Boolean Boolean Boolean Boolean

Whether to display progress of the operation. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption UICancelOption UICancelOption UICancelOption

Action to be taken when the user clicks Cancel. Default is ThrowException.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

UploadFile(String, String) UploadFile(String, String) UploadFile(String, String) UploadFile(String, String)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, System::String ^ address);
public void UploadFile (string sourceFileName, string address);
member this.UploadFile : string * string -> unit
Public Sub UploadFile (sourceFileName As String, address As String)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
String String String String

URL, IP address, or URI of destination server.

Exceptions

User lacks necessary permissions to perform a network operation.

The server does not respond within the default timeout (100 seconds).

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

You can use one of the other overloads of the UploadFile method to provide user credentials or specify a specific timeout value.

My.Computer.Network.UploadFile outputs trace information when you enable network tracing in your application. For more information, see Enabling Network Tracing.

The following table lists an example of a task involving the My.Computer.Network.UploadFile method.

To See
Upload a file How to: Upload a File

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

WebPermission
Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.

See also

UploadFile(String, Uri) UploadFile(String, Uri) UploadFile(String, Uri) UploadFile(String, Uri)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address);
public void UploadFile (string sourceFileName, Uri address);
member this.UploadFile : string * Uri -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

Exceptions

User lacks necessary permissions to perform a network operation.

The server does not respond within the default timeout (100 seconds).

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

You can use one of the other overloads of the UploadFile method to provide user credentials or specify a specific timeout value.

My.Computer.Network.UploadFile outputs trace information when you enable network tracing in your application. For more information, see Enabling Network Tracing.

The following table lists an example of a task involving the My.Computer.Network.UploadFile method.

To See
Upload a file How to: Upload a File

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

WebPermission
Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.

See also

UploadFile(String, String, String, String) UploadFile(String, String, String, String) UploadFile(String, String, String, String) UploadFile(String, String, String, String)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, System::String ^ address, System::String ^ userName, System::String ^ password);
public void UploadFile (string sourceFileName, string address, string userName, string password);
member this.UploadFile : string * string * string * string -> unit
Public Sub UploadFile (sourceFileName As String, address As String, userName As String, password As String)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
String String String String

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the default timeout (100 seconds).

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

You can use one of the other overloads of the UploadFile method to specify a specific timeout value.

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 How to: Upload a File

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

WebPermission
Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.

See also

UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String) UploadFile(String, Uri, String, String)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address, System::String ^ userName, System::String ^ password);
public void UploadFile (string sourceFileName, Uri address, string userName, string password);
member this.UploadFile : string * Uri * string * string -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri, userName As String, password As String)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the default timeout (100 seconds).

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

You can use one of the other overloads of the UploadFile method to specify a specific timeout value.

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 How to: Upload a File

Security

FileIOPermission
Controls the ability to access files and folders. Associated enumeration: Unrestricted.

WebPermission
Controls rights to access HTTP Internet resources. Associated enumeration: Unrestricted.

See also

UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32) UploadFile(String, Uri, ICredentials, Boolean, Int32)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address, System::Net::ICredentials ^ networkCredentials, bool showUI, int connectionTimeout);
public void UploadFile (string sourceFileName, Uri address, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout);
member this.UploadFile : string * Uri * System.Net.ICredentials * bool * int -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri, networkCredentials As ICredentials, showUI As Boolean, connectionTimeout As Integer)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

networkCredentials
ICredentials ICredentials ICredentials ICredentials

Credentials for authentication.

showUI
Boolean Boolean Boolean Boolean

True to display progress of the operation; otherwise False. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32) UploadFile(String, String, String, String, Boolean, Int32)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, System::String ^ address, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout);
public void UploadFile (string sourceFileName, string address, string userName, string password, bool showUI, int connectionTimeout);
member this.UploadFile : string * string * string * string * bool * int -> unit
Public Sub UploadFile (sourceFileName As String, address As String, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
String String String String

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

showUI
Boolean Boolean Boolean Boolean

True to display progress of the operation; otherwise False. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption) UploadFile(String, Uri, ICredentials, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address, System::Net::ICredentials ^ networkCredentials, bool showUI, int connectionTimeout, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void UploadFile (string sourceFileName, Uri address, System.Net.ICredentials networkCredentials, bool showUI, int connectionTimeout, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.UploadFile : string * Uri * System.Net.ICredentials * bool * int * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri, networkCredentials As ICredentials, showUI As Boolean, connectionTimeout As Integer, onUserCancel As UICancelOption)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

networkCredentials
ICredentials ICredentials ICredentials ICredentials

Credentials for authentication.

showUI
Boolean Boolean Boolean Boolean

True to display progress of the operation; otherwise False. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption UICancelOption UICancelOption UICancelOption

Action to be taken when the user clicks Cancel. Default is ThrowException.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32) UploadFile(String, Uri, String, String, Boolean, Int32)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout);
public void UploadFile (string sourceFileName, Uri address, string userName, string password, bool showUI, int connectionTimeout);
member this.UploadFile : string * Uri * string * string * bool * int -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

showUI
Boolean Boolean Boolean Boolean

True to display progress of the operation; otherwise False. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption) UploadFile(String, Uri, String, String, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

public:
 void UploadFile(System::String ^ sourceFileName, Uri ^ address, System::String ^ userName, System::String ^ password, bool showUI, int connectionTimeout, Microsoft::VisualBasic::FileIO::UICancelOption onUserCancel);
public void UploadFile (string sourceFileName, Uri address, string userName, string password, bool showUI, int connectionTimeout, Microsoft.VisualBasic.FileIO.UICancelOption onUserCancel);
member this.UploadFile : string * Uri * string * string * bool * int * Microsoft.VisualBasic.FileIO.UICancelOption -> unit
Public Sub UploadFile (sourceFileName As String, address As Uri, userName As String, password As String, showUI As Boolean, connectionTimeout As Integer, onUserCancel As UICancelOption)

Parameters

sourceFileName
String String String String

Path and name of file to upload.

address
Uri Uri Uri Uri

URL, IP address, or URI of destination server.

userName
String String String String

User name to authenticate. Default is an empty string: "".

password
String String String String

Password to authenticate. Default is an empty string: "".

showUI
Boolean Boolean Boolean Boolean

Whether to display progress of the operation. Default is False.

connectionTimeout
Int32 Int32 Int32 Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption UICancelOption UICancelOption UICancelOption

Action to be taken when the user clicks Cancel. Default is ThrowException.

Exceptions

connectionTimeout is less than or equal to zero.

User lacks necessary permissions to perform a network operation.

The server does not respond within the specified connectionTimeout.

The request is denied by the target web server.

Examples

This example uploads the file Order.txt to http://www.cohowinery.com/uploads.

My.Computer.Network.UploadFile ( "C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx")

This example uploads the file Order.txt to http://www.cohowinery.com/uploads without supplying a user name or password, shows the progress of the upload, and has a time-out interval of 500 milliseconds.

My.Computer.Network.UploadFile ("C:\My Documents\Order.txt", 
"http://www.cohowinery.com/upload.aspx","","",True,500)

Remarks

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 How to: Upload a File

Security

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.

See also

Applies to