I'm using the following code:
VB Code:
Private Sub Copy_Folder(From_ As String, To_ As String) If Len(Dir$(To_, vbDirectory)) > 0 Then objFS.DeleteFolder To_ objFS.CreateFolder To_ Else objFS.CreateFolder To_ End If objFS.CopyFolder From_, To_ End Sub
I'm trying to copy all the contents off my K drive into D:\Backup.
The program i'm trying to create automatically backs up my USB key apon being plugged in (that bit i'm still working on), for now i'm trying to just get it to copy the contents of the USB device!
The error i get is:
Run-time Error '5':
Invalid procedure call or argument
I have code that creates another folder inside the backup folder (with the date and time inside the name), but i don't think that that is causing the problem.
VB Code:
Private Sub Backup_Event() Dim Tmp_Dest As String If ChkOverWrite.Value = 0 Then Tmp_Dest = BackUpDirTxt.Text & "\BU (" & DriveLetter.Text & ") - " & Get_Date_Time Copy_Folder DriveLetter.Text & ":\", Tmp_Dest Else If ChkOverWrite.Value = 1 Then Tmp_Dest = BackUpDirTxt.Text & "\BU (" & DriveLetter.Text & ")" Copy_Folder DriveLetter.Text & ":\", Tmp_Dest End If End If End Sub Public Function Get_Date_Time() Dim sTime As SYSTEMTIME GetLocalTime sTime Get_Date_Time = sTime.wYear & sTime.wMonth & sTime.wDay & sTime.wHour & sTime.wMinute & sTime.wSecond End Function
Please note that the overwrite checkbox isn't used for overwriting. It detmines whether a new folder should be made with the date & time, or if it just saves to the one folder each time.
I have tried putting a True or False on the end ofbut it doesn't make a difference.VB Code:
objFS.CopyFolder From_, To_
Thank you!




Reply With Quote