by Karthikeyan (187 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 15th December 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Copy a file using CopyFile API
Dim retval As Long ' return value
' copy the file
retval = CopyFile("D:\sample.txt", "D:\example.txt", 1)
If retval = 0 Then ' failure
MsgBox "Copy failed -- D:\example.txt already exists."
Else ' success
MsgBox "Copy succeeded."
End If
End
End Sub