Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic
 How to: Upload a File

  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:
Visual Basic Application Development
How to: Upload a File in Visual Basic

The My.Computer.Network.UploadFile Method can be used to upload a file and store it to a remote location. If the ShowUI parameter is set to True, a dialog box is displayed that shows the progress of the download and allows users to cancel the operation.

To upload a file

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI (Uniform Resource Identifier).This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx.

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

To upload a file and show the progress of the operation

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI. This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx 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)
    
    

To upload a file, supplying a user name and password

  • Use the UploadFile method to upload a file, specifying the source file's location and the target directory location as a string or URI, and specifying the user name and the password. This example uploads the file Order.txt to http://www.cohowinery.com/uploads.aspx, supplying the user name anonymous and a blank password.

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

The following conditions may throw an exception:

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