Results 1 to 3 of 3

Thread: [RESOLVED] FTP: Create Directory

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2010
    Posts
    43

    Resolved [RESOLVED] FTP: Create Directory

    Thanks to this thread I found out about a very straightforward way in VB 2010 to upload & download files via FTP (shown below). What is the most straightforward way to create a directory on my FTP server, delete a file on the server, and check for a file or directory's existence on the server, please?

    I didn't see anything in the intellisense that seems to correspond to these tasks, and the articles I'm finding via Google etc all seem to have fairly lengthy solutions for these sorts of tasks, and the upload/download tasks as well. The existence of such a compact solution in VS 2010 for the latter tasks makes me suspect that there may be something similar for the former as well, but I've not located it yet.

    Many thanks,

    H.B.

    Code:
            Dim FileOnServer As String = "ftp://ftp.mydomain.com/subdir/myfile.txt"
            Dim LocalFile As String = "C:\FTP_Test_result.txt"
            Dim UserName As String = "[email protected]"
            Dim Password As String = "mypassword"
    
            If My.Computer.FileSystem.FileExists(LocalFile) Then            
                My.Computer.FileSystem.DeleteFile(LocalFile)
            End If
    
            My.Computer.Network.DownloadFile(FileOnServer, LocalFile, UserName, Password)

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

    Re: FTP: Create Directory

    You'll need to use an FtpWebRequest and FtpWebResponse for that. Start by reading the documentation for those classes to see how they work and what members they have. You can then search this form and the VB.NET CodeBank forum for examples. If you have any specific issues then post back with what you've done and where you're stuck.
    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
    Member
    Join Date
    Apr 2010
    Posts
    43

    Re: FTP: Create Directory

    Cool, thanks -- I'll pursue that. I'd seen FTPWebRequest, but from the documentation I saw on it I wasn't sure that it was what I needed, or at least not the simplest way to go about it. I'll go deeper into that now.

    Thanks for pointing me in the right direction!

    HB

Tags for this Thread

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