I have managed to get it so I can create the folder structure that I want the backed up files to be stored in, if the folder doesn't exist and it names a new folder within "Backed up files" with todays date for periodic back ups. However, what I'm having trouble with is getting it to copy files.
What I want it to be able to do is to use wildcards (But I arn't sure how I'd do this) to copy any ".txt", ".accdb" and ".exe" files to the newly created location.
Heres the visual basic 6 code I've got so far
Any help from you guys would be deeply appreciated
What I want it to be able to do is to use wildcards (But I arn't sure how I'd do this) to copy any ".txt", ".accdb" and ".exe" files to the newly created location.
Heres the visual basic 6 code I've got so far
Code:
'Variables that are used to create the folder structure
Dim backuplocation, newlocation, customdate As String
'Variables that are used to copy the files
Dim filesel, newfilelocation, currentfilelocation As String
Private Sub cmdbackuplocation_Click()
MkDir backuplocation
cmdbackuplocation.Visible = False
cmdtodaysbackup.Visible = True
End Sub
Private Sub cmdtodaysbackup_Click()
Dim currentfilelocation1, currentfilelocation2, currentfilelocation3 As String
currentfilelocation1 = App.Path & "\" & "*" & ".txt"
currentfilelocation2 = App.Path & "\" & "*" & ".accdb"
currentfilelocation3 = App.Path & "\" & ""*" & ".exe"
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This creates the customised dated new folder
customdate = DatePart("w", Now) & "-" & DatePart("m", Now) & "-" & DatePart("yyyy", Now)
newlocation = backuplocation & "Back-up Created On" & " " & customdate & "\"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
newfilelocation = newlocation & "Test.txt"
If Dir(newlocation, vbDirectory) <> "" Then
MsgBox "Todays back-up has already been made"
cmdtodaysbackup.Enabled = False
cmdbackuplocation.Enabled = False
Else
MsgBox "About to complete todays back-up"
MkDir newlocation
MsgBox "Todays back-up now exists"
End If
MsgBox currentfilelocation1
FileCopy currentfilelocation1, newfilelocation
MsgBox currentfilelocation2
FileCopy currentfilelocation2, newfilelocation
MsgBox currentfilelocation3
FileCopy currentfilelocation3, newfilelocation
MsgBox "Back-Up complete"
cmdtodaysbackup.Visible = False
End Sub
Private Sub Drive1_Change()
backuplocation = Left$(Drive1.Drive, 1) & ":\LiveEarth_Backup\"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This checks to see if theres a folder in the root of the selected drive called "LiveEarth_Backup"
If Dir(backuplocation, vbDirectory) <> "" Then
'if there is then todays back up is visible for the user to create todays back up
cmdtodaysbackup.Visible = True
cmdbackuplocation.Visible = False
Else
'if there isn't then backuplocation is visible which allows the user to create it
cmdbackuplocation.Visible = True
cmdtodaysbackup.Visible = False
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Private Sub Form_Load()
MsgBox "Please select the drive you wish to back up this software too"
backuplocation = Left$(Drive1.Drive, 1) & ":\LiveEarth_Backup\"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'This checks to see if theres a folder in the root of the selected drive called "LiveEarth_Backup"
If Dir(backuplocation, vbDirectory) <> "" Then
'if there is then todays back up is visible for the user to create todays back up
cmdtodaysbackup.Visible = True
cmdbackuplocation.Visible = False
Else
'if there isn't then backuplocation is visible which allows the user to create it
cmdbackuplocation.Visible = True
cmdtodaysbackup.Visible = False
End If
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
End Sub
Any help from you guys would be deeply appreciated
