Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Network Class
Network Methods
UploadFile Method
 UploadFile Method (String, String, ...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
Network..::.UploadFile Method (String, String, String, String, Boolean, Int32, UICancelOption)

Sends the specified file to the specified host address.

Namespace:  Microsoft.VisualBasic.Devices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Visual Basic (Declaration)
Public Sub UploadFile ( _
    sourceFileName As String, _
    address As String, _
    userName As String, _
    password As String, _
    showUI As Boolean, _
    connectionTimeout As Integer, _
    onUserCancel As UICancelOption _
)
Visual Basic (Usage)
Dim instance As Network
Dim sourceFileName As String
Dim address As String
Dim userName As String
Dim password As String
Dim showUI As Boolean
Dim connectionTimeout As Integer
Dim onUserCancel As UICancelOption

instance.UploadFile(sourceFileName, address, _
    userName, password, showUI, connectionTimeout, _
    onUserCancel)
C#
public void UploadFile(
    string sourceFileName,
    string address,
    string userName,
    string password,
    bool showUI,
    int connectionTimeout,
    UICancelOption onUserCancel
)
Visual C++
public:
void UploadFile(
    String^ sourceFileName, 
    String^ address, 
    String^ userName, 
    String^ password, 
    bool showUI, 
    int connectionTimeout, 
    UICancelOption onUserCancel
)
JScript
public function UploadFile(
    sourceFileName : String, 
    address : String, 
    userName : String, 
    password : String, 
    showUI : boolean, 
    connectionTimeout : int, 
    onUserCancel : UICancelOption
)

Parameters

sourceFileName
Type: System..::.String
String. Path and name of file to upload. Required.
address
Type: System..::.String
String or Uri. URL, IP address, or URI of destination server. Required.
userName
Type: System..::.String
String. User name to authenticate. Default is an empty string: "".
password
Type: System..::.String
String. Password to authenticate. Default is an empty string: "".
showUI
Type: System..::.Boolean
Boolean. Whether to display progress of the operation. Default is False.
connectionTimeout
Type: System..::.Int32
Int32. Timeout interval in milliseconds. Default is 100 seconds.
onUserCancel
Type: Microsoft.VisualBasic.FileIO..::.UICancelOption
UICancelOption. Action to be taken when the user clicks Cancel. Default is ThrowException.

For more detailed information, see the Visual Basic topic My.Computer.Network.UploadFile Method.

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.

Security noteSecurity 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.

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

Visual Basic
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.

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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker