Редагувати

Поділитися через


Network.UploadFile Method

Definition

Sends the specified file to the specified host address.

Overloads

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

Sends the specified file to the specified host address.

UploadFile(String, String)

Sends the specified file to the specified host address.

UploadFile(String, Uri)

Sends the specified file to the specified host address.

UploadFile(String, String, String, String)

Sends the specified file to the specified host address.

UploadFile(String, Uri, String, String)

Sends the specified file to the specified host address.

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

Sends the specified file to the specified host address.

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

Sends the specified file to the specified host address.

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

Sends the specified file to the specified host address.

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

Sends the specified file to the specified host address.

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)

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
String

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption

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

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

UploadFile(String, String)

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
String

URL, IP address, or URI of destination server.

Exceptions

The source file path is not valid.

address does not include a file name.

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

See also

Applies to

UploadFile(String, Uri)

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

Exceptions

The source file path is not valid.

address does not include a file name.

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

See also

Applies to

UploadFile(String, String, String, String)

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
String

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

UploadFile(String, Uri, String, String)

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

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

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

networkCredentials
ICredentials

Credentials for authentication.

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

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

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
String

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

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

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

networkCredentials
ICredentials

Credentials for authentication.

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption

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

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

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

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to

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

Source:
Network.vb
Source:
Network.vb
Source:
Network.vb

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

Path and name of file to upload.

address
Uri

URL, IP address, or URI of destination server.

userName
String

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

password
String

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

showUI
Boolean

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

connectionTimeout
Int32

Timeout interval in milliseconds. Default is 100 seconds.

onUserCancel
UICancelOption

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

Exceptions

connectionTimeout is less than or equal to zero.

address does not include a file name.

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

See also

Applies to