Results 1 to 7 of 7

Thread: [02/03] FTP a file How to ?

  1. #1

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    [02/03] FTP a file How to ?

    Hi,

    How to upload a file using FTP ? in 2003

    can someone help me on this.

    thanks in advance
    Kanna

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] FTP a file How to ?

    WebClient.UploadFile for simple scenarios, FtpWebRequest for more complex scenarios.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: [02/03] FTP a file How to ?

    thanks will try now
    Kanna

  4. #4

    Thread Starter
    Hyperactive Member csKanna's Avatar
    Join Date
    Dec 2005
    Location
    Tech-Tips-Now.com
    Posts
    339

    Re: [02/03] FTP a file How to ?

    ok. Here is my code
    vb Code:
    1. Imports System.net
    2. Module Module1
    3.  
    4.     Sub Main()
    5.         'system.Net.WebClient.UploadFile(
    6.         Dim uriString As String = "ftp://username:[email protected]/public_html/Temp/test.txt"
    7.  
    8.         ' Create a new WebClient instance.
    9.         Dim myWebClient As New WebClient
    10.  
    11.         Dim fileName As String = "C:\Temp\test.txt"
    12.         Console.WriteLine("Uploading {0} to {1} ...", fileName, uriString)
    13.  
    14.         ' Upload the file to the URI.
    15.         ' The 'UploadFile(uriString,fileName)' method implicitly uses HTTP POST method.
    16.         Dim responseArray As Byte() = myWebClient.UploadFile(uriString, fileName)
    17.  
    18.         ' Decode and display the response.
    19.         Console.WriteLine(ControlChars.Cr & "Response Received.The contents of the file uploaded are: " & _
    20.             ControlChars.Cr & "{0}", System.Text.Encoding.ASCII.GetString(responseArray))
    21.     End Sub
    22. End Module
    am getting an error saying
    Code:
    An exception occurred during a WebClient request.
    Kanna

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [02/03] FTP a file How to ?

    I'm not sure that you can include the credentials in the URL like that with a WebClient. The object has a Credentials property. Try setting that and then just using the plain URL.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6
    Frenzied Member
    Join Date
    Jan 2008
    Posts
    1,754

    Re: [02/03] FTP a file How to ?

    I write in 2005/2008 so im not sure if 02/03 has this.

    Can't you use:

    vb.net Code:
    1. My.Computer.Network

  7. #7
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,018

    Re: [02/03] FTP a file How to ?

    Quote Originally Posted by noahssite
    I write in 2005/2008 so im not sure if 02/03 has this.

    Can't you use:

    vb.net Code:
    1. My.Computer.Network
    Unfortunately the My namespace was introduced in 2005.
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width