Results 1 to 5 of 5

Thread: [02/03] FTP and Unzipping!

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    137

    [02/03] FTP and Unzipping!

    I use VB.NET VB!

    Can somebody point me in the right direction?

    I will use the command: wclient.DownloadFile("http://www.domain.com/myfile.zip") to download compressed file from the web!

    Is there any way to unzip the contents to a folder on the computer e.g. c:/my-windows-application/myfile/...
    ???

    Then, I wish to upload the files using FTP! How would I upload the folder via ftp?

    thanks peeps

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [02/03] FTP and Unzipping!

    Have you tried the code bank? I seem to remember someone (JMC?) writing a zip application or something. I don't know if it auto unzips files though.

    EDIT - Check this out

    I haven't seen any examples of uploading folders I'm afraid. One alternative that may be more viable is to just create a directory in the ftp server and then upload each of the files through a loop which should be easy. If you manage to do the auto unzip then just get the folder name that it creates and then create that on the ftp server. Check out this post about creating directories on ftp:

    FTP folder creation
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    137

    Re: [02/03] FTP and Unzipping!

    Hello,

    Thank You for the links!

    I can use that code to CreateDirectories and Upload individual files!

    I have the knowledge to do a loop for all files in a diectory, but there will be sub-directories, and sub-sub-directories ect from the ZIP files, so how would i get it to loop through all folders.

    E.g. File structure:

    File 1
    Fil 2
    File 3
    File 4
    Directory 1 --> SubDir1
    Dir 2 --> SubDir 1 --> SubSubDir1 --> SubSubDir1
    -------> SubDir 2
    Dir 3 --> File 1
    -------> File 2
    -------> File 3
    -------> Dir 1 --> File 1
    ------------- --> File 2

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2006
    Posts
    137

    Re: [02/03] FTP and Unzipping!

    OR

    Is there a PHP script that will unzip a compressed file to a FTP location?

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

    Re: [02/03] FTP and Unzipping!

    A folder tree is a recursive structure, thus the way to traverse a folder tree is using recursion. That means that for a folder you call a method that creates the corresponding FTP folder and then uploads the files, then call that same method for each subfolder of that folder, then each subfolder of each subfolder, etc. There's at least one example of a recursive file search in the CodeBank. You'd apply a similar principle here. Having said that, recursion is usually taught fairly early on in most programming courses. Here's a simple method that, when called with a folder path, will display the full path of each file in the folder and all subfolders:
    VB Code:
    1. Public Sub ShowFilePaths(ByVal folderPath As String)
    2.     For Each filePath As String In IO.Directory.GetFiles(folderPath)
    3.         Console.WriteLine(filePath)
    4.     Next filePath
    5.  
    6.     For Each subfolderPath As String In IO.Directy.GetDirectories(folderPath)
    7.         'Here's the recursive call.
    8.         Me.ShowFilePaths(subfolderPath)
    9.     Next subfolderPath
    10. End Sub
    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

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