Make your own free website on

Move 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 MoveFile Lib "kernel32" Alias "MoveFileA" (ByVal _
lpExistingFileName As String, ByVal lpNewFileName As String) As Long

'Insert the following code to your form:

Private Sub Command1_Click()
'This Example will move 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 = MoveFile("c:\MyFile.Zip", "c:\MyDir\MyFile.Zip")
If A Then
MsgBox "File moved!"
MsgBox "Error. File not moved!"
End If
End Sub

Go Back