Make your own free website on Tripod.com

Copy File

'Add a module to your project (In the menu choose Project -> Add Module, Then click Open)
'Insert the following code to your module:

Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal _
lpExistingFileName As String, ByVal lpNewFileName As String, ByVal _
bFailIfExists As Long) As Long

'Insert the following code to your form:

Private Sub Command1_Click()
'This Example will copy the file 'c:\MyFile.Zip' to the directory 'c:\MyDir'.
'If the file already exist in 'c:\MyDir' it will overwrite it. To disallow overwriting,
'Replace the 'False' below with 'True'

A = CopyFile("c:\MyFile.Zip", "c:\MyDir\MyFile.Zip", False)
If A Then
MsgBox "File copied!"
Else
MsgBox "Error. File not copied!"
End If
End Sub

Go Back