locked
Downloading files RRS feed

  • Question

  •  

    ok i need to download a file from my website. the problem is the website wont allow me to download the file unless its through ftp. it needs a login name and password to access it. i need just a simple code that will ftp to the website download this file to My Documents folder then once im done getting the information from the file i need code to delete the file from the My Documents folder

     

    thanks

     

    Mike

    Sunday, January 20, 2008 5:35 AM

Answers

  •  Michael Morris wrote:

    ftp to the website download this file to My Documents folder then once im done getting the information from the file i need code to delete the file from the My Documents folder

     

    Hi Mike,

     

    Besides FTPWebRequest class Renee mentioned, you also use:

    My.Computer.Network.DownloadFile Method 

    Downloads the specified remote file and saves it in the specified location.

    http://msdn2.microsoft.com/en-us/library/ack30t8y(vs.80).aspx

     

    My.Computer.Network.DownloadFile(address ,destinationFileName ,userName ,password)

    My.Computer.Network.DownloadFile(address ,destinationFileName ,userName ,password ,showUI ,connectionTimeout ,overwrite)

    Parameters

    address

    String or Uri. Path of the file to download, including file name and host address. Required.

    destinationFileName

    String. File name and path of the downloaded file. Required.

    userName

    String. User name to authenticate. Default is an empty string, "".

    password

    String.Password to authenticate. Default is an empty string, "".

    showUI

    Boolean. Specifies whether to display the progress of the operation. Default is False.

    connectionTimeout

    Int32. Timeout interval, in milliseconds. Default is 100 seconds.

    overwrite

    Boolean. Specifies whether to overwrite existing files. Default is False.

     

    For example:

    Code Block

    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

     

            Dim MyDocFolder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments

            My.Computer.Network.DownloadFile("\\MartinXie\Share\1.doc", MyDocFolder & "\2.doc", "fareast\Martin", "ShanghaiPassword")

            IO.File.Delete("\\MartinXie\Share\1.doc")

     

        End Sub

    End Class

     

     

    Monday, January 21, 2008 9:08 AM

All replies

  • " i need a code to delete the file from the My Documents "

     

    You need code. Never "a code".

    Sunday, January 20, 2008 6:01 AM
  •  Michael Morris wrote:

    ftp to the website download this file to My Documents folder then once im done getting the information from the file i need code to delete the file from the My Documents folder

     

    Hi Mike,

     

    Besides FTPWebRequest class Renee mentioned, you also use:

    My.Computer.Network.DownloadFile Method 

    Downloads the specified remote file and saves it in the specified location.

    http://msdn2.microsoft.com/en-us/library/ack30t8y(vs.80).aspx

     

    My.Computer.Network.DownloadFile(address ,destinationFileName ,userName ,password)

    My.Computer.Network.DownloadFile(address ,destinationFileName ,userName ,password ,showUI ,connectionTimeout ,overwrite)

    Parameters

    address

    String or Uri. Path of the file to download, including file name and host address. Required.

    destinationFileName

    String. File name and path of the downloaded file. Required.

    userName

    String. User name to authenticate. Default is an empty string, "".

    password

    String.Password to authenticate. Default is an empty string, "".

    showUI

    Boolean. Specifies whether to display the progress of the operation. Default is False.

    connectionTimeout

    Int32. Timeout interval, in milliseconds. Default is 100 seconds.

    overwrite

    Boolean. Specifies whether to overwrite existing files. Default is False.

     

    For example:

    Code Block

    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

     

            Dim MyDocFolder As String = My.Computer.FileSystem.SpecialDirectories.MyDocuments

            My.Computer.Network.DownloadFile("\\MartinXie\Share\1.doc", MyDocFolder & "\2.doc", "fareast\Martin", "ShanghaiPassword")

            IO.File.Delete("\\MartinXie\Share\1.doc")

     

        End Sub

    End Class

     

     

    Monday, January 21, 2008 9:08 AM