by Shrinivas Deshpande (1 Submission)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 22nd October 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Copy a file to a backup folder
API Declarations
one drive list box
one combo box
one dir lilst box
two file list box
two label with caption select file to copy and select file to delete as label2 and label3
File1.Pattern = Combo1.Text
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub Drive1_Change()
On Error GoTo this
Dir1.Path = Drive1.Drive
this:
If Err.Number > 0 Then
MsgBox ("Device not ready")
End If
End Sub
Private Sub File1_Click()
Dim FSys As New FileSystemObject
If Right(File1.Path, 1) = "\" Then
yourfile = File1.Path + File1.FileName
Else
yourfile = File1.Path + "\" + File1.FileName
End If
FSys.CopyFile yourfile, "f:\backup\"
Label1.Caption = File1.FileName + " is copied "
File2.Refresh
End Sub
Private Sub File1_Mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.ForeColor = vbWhite
End Sub
Private Sub File1_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label2.ForeColor = vbCyan
End Sub
Private Sub File2_Mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = vbWhite
End Sub
Private Sub File2_Mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.ForeColor = vbCyan
End Sub
Private Sub File2_Click()
Dim FSys As New FileSystemObject
If Right(File2.Path, 1) = "\" Then
yourfile2 = File2.Path + File2.FileName
Else
yourfile2 = File2.Path + "\" + File2.FileName
End If
Label1.Caption = File2.FileName + " is deleted "
FSys.DeleteFile yourfile2
File2.Refresh
End Sub