Author : Shrinivas Deshpande
Date Submitted : 10/22/2007
Category : File Manipulation
Compatibility : VB 6
This code has been accessed 5890 times.
Task : Copy a file to a backup folder
Declarations
Code
Private Sub Combo1_Change()
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