PDA

Click to See Complete Forum and Search --> : Inet Folder Copying


jsmith
Mar 20th, 2000, 08:49 PM
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.

Mar 21st, 2000, 06:03 PM
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).



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

damasterjo
Nov 17th, 2008, 03:05 PM
is this visual basic 6?

damasterjo
Nov 18th, 2008, 08:26 AM
i get a user defined type not defined error here. why??