Results 1 to 4 of 4

Thread: Inet Folder Copying

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2000
    Location
    baltimore,md,usa
    Posts
    6
    I created connection and can copy files, but can't not copy folders from harddrive to ftp. Is there something like getchunk i can use on my harddrive? Does anyone knows how to copy folders, or the only way is mkdir, but what loop do I need.

  2. #2
    Guest
    Loop trough all the sub dirs and upload the files.

    Here is something i made when i needed to upload a dir with all files and subdirs.

    All you need to change is:
    Inet1.URL = "ftp://[INSERT IP]"
    Inet1.UserName = "[USER NAME]"
    Inet1.Password = "[PASSWORD]"
    ReadDir "C:\Upload Folder", "/Destination", Inet1

    Just insert your own values there
    And add a label called label1(it displays some progress stuff in it).


    Code:
    Option Explicit
    
    Private Sub ReadDir(ByVal sLocalDir As String, ByVal sTargetDir As String, ByVal Inet As Inet)
        Dim asDir() As String
        Dim sTemp As String
        Dim lCounter As Long
        
        'Create target folder
        Label1 = "Creating dir: " & sTargetDir
        Inet.Execute Inet.URL, "mkdir " & sTargetDir
        Do Until Inet.StillExecuting = False
            DoEvents
        Loop
        'Change To Dir
        Inet.Execute Inet.URL, "cd " & sTargetDir
        Do Until Inet.StillExecuting = False
            DoEvents
        Loop
        
        'Append slash if it aint here
        If Right$(sLocalDir, 1) <> "\" Then
            sLocalDir = sLocalDir & "\"
        End If
        ReDim asDir(0)
        
        'Read Localdir
        sTemp = Dir(sLocalDir, vbDirectory)   ' Retrieve the first entry.
        Do While sTemp <> ""   ' Start the loop.
            'Ignore the current directory and the encompassing directory.
            If sTemp <> "." And sTemp <> ".." Then
                'Use bitwise comparison to make sure MyName is a directory.
                If (GetAttr(sLocalDir & sTemp) And vbDirectory) = vbDirectory Then
                    asDir(UBound(asDir)) = sTemp
                    ReDim Preserve asDir(UBound(asDir) + 1)
                End If   ' it represents a directory.
            End If
            sTemp = Dir   ' Get next entry.
        Loop
        
        'Read all sub dirs
        If UBound(asDir) > 0 Then
            ReDim Preserve asDir(UBound(asDir) - 1)
            'Proccess Sub Dirs
            For lCounter = LBound(asDir) To UBound(asDir)
                Do Until Inet.StillExecuting = False
                    DoEvents
                Loop
                ReadDir sLocalDir & asDir(lCounter), sTargetDir & "/" & asDir(lCounter), Inet   'Read This Subdir
            Next
        End If
        
        'Upload Files
        sTemp = Dir(sLocalDir)
        Do While sTemp <> ""
            Label1 = "Uploading file: " & sLocalDir & sTemp
            'Upload this file
            Inet.Execute Inet.URL, "put """ & sLocalDir & sTemp & """ """ & sTargetDir & "/" & sTemp & """"
            Do Until Inet1.StillExecuting = False
                DoEvents
            Loop
            sTemp = Dir
        Loop
        
        'Move up one dir before we go to the next sub dir
        Inet.Execute Inet.URL, "cd .."
        Do Until Inet.StillExecuting = False
            DoEvents
        Loop
    End Sub
    
    Private Sub Command1_Click()
        Inet1.URL = "ftp://[INSERT IP]"
        Inet1.UserName = "[USER NAME]"
        Inet1.Password = "[PASSWORD]"
        ReadDir "C:\Upload Folder", "/Destination", Inet1
    End Sub

    Hope it helps

  3. #3
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Inet Folder Copying

    is this visual basic 6?
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

  4. #4
    Fanatic Member damasterjo's Avatar
    Join Date
    Nov 2005
    Location
    In front of my Comp DirectX7 EXpert
    Posts
    827

    Re: Inet Folder Copying

    i get a user defined type not defined error here. why??
    Software languages known:
    Qbasic - TI-Basic - Liberty Basic - Visual Basic 6
    Software API's known:
    Directx 7 and 8
    Internet languages, in the process of learning:
    HTML - JAVASCRIPT - PHP - CSS - MYSQL - AJAX

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