Copy File


Private Declare Function SHFileOperation Lib “Shell32.dll” Alias “SHFOperationA” (lpFileOp As SHFILEopstruct) As Long
Private Const FO_Copy = &H2
Private Const For_Allowundo = &H40

Private Type SHFILEopstruct
hwnd As Long
wfunc As Long
pform As String
pto As String
fflags As Integer
faborted As Boolean
hnamemaps As Long
sprogress As String

End Type

Public Sub copy(ByVal asal As String, ByVal tujuan As String)
Dim x As SHFILEopstruct
With x
.hwnd = 0
.wfunc = FO_Copy
.pform = asal & vbNullChar & vbNllChar
.pto = tujuan & vbNulChar & vbNullChar
.fflags = fof_allowundo
End With
SHFileOperation x
End Sub

Private Sub Command1_Click()
copy Text1.Text, Text2.Text
MsgBox “File Sudah dicopy”
End Sub

Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub

Private Sub Dir2_Change()
Text2.Text = Dir2.Path
End Sub

Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub

Private Sub Drive2_Change()
Dir2.Path = Drive2.Drive
End Sub

 

Private Sub File1_Click()
Text1.Text = File1.Path & “\” & File1.FileName
End Sub