UploadFile Method


UploadFile Method

Location

My.Computer.Network.UploadFile

Syntax

     My.Computer.Network.UploadFile(sourceFileName, address _        [, username, password[, showUI, connectionTimeout _    [, onUserCancel]]]) 

or:

     My.Computer.Network.UploadFile(sourceFileName, uri _        [, username, password[, showUI, connectionTimeout _    [, onUserCancel]]]) 

or:

     My.Computer.Network.UploadFile(sourceFileName, uri, _    networkCredentials, showUI, connectionTimeout[, onUserCancel]) 


sourceFileName (required; String)

The local source path of the file to be uploaded.


address (required in syntax 1; String)

The destination web site address, including the full URL path.


uri (required in syntax 2 and 3; System.Uri)

The uniform resource identifier (URI) of the destination web site address.


username (optional; String)

The network user name for authentication purposes. If supplied, password must also be used.


password (optional; String)

The network password for authentication purposes. If supplied, username must also be used.


showUI (optional; Boolean)

Indicates whether a progress window should appear during the upload. By default, no progress window appears.


connectionTimeout (optional; Integer)

The number of seconds to wait before failure. By default, the timeout is 100 seconds.


onUserCancel (optional; UICancelOption enumeration)

The progress window includes a Cancel button. When pressed, the method takes action based on this parameter. One of the following Microsoft.VisualBasic.FileIO.UICancelOption enumeration values.

Value

Description

DoNothing

Aborts the upload but returns no information indicating that the upload was cancelled

ThrowException

Throws an exception


If this parameter is missing, ThrowException is used by default.


networkCredentials (required in syntax 3; ICredentials interface)

The credentials to be supplied for authentication purposes, based on the System.Net.ICredentials interface.

Description

The UploadFile method sends a local file to a remote server via a web page that supports file uploading.

Usage at a Glance

  • An exception is thrown if the source or destination path is invalid, or if the destination web site denies the request.

  • An exception is thrown if the user has invalid or insufficient security permissions to perform the download.

  • An exception is thrown if a connection timeout occurs due to a lack of server response.

Example

The following example uploads a local file to a web site.

     My.Computer.Network.UploadFile _        ("C:\PriceList.txt", "http://www.oreilly.com/upload.aspx", ) 

Related Framework Entries

  • Microsoft.VisualBasic.Devices.Network.UploadFile Method

See Also

Network Object, DownloadFile Method




Visual Basic 2005(c) In a Nutshell
Visual Basic 2005 in a Nutshell (In a Nutshell (OReilly))
ISBN: 059610152X
EAN: 2147483647
Year: 2004
Pages: 712

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net