CopyFile API Function
CopyFile API function is very similar to DeleteFile function i showed to You couple weeks ago. You can use this function to copy files from one location to another fast and easy.
The declaration of CopyFile:
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
All this code above has to be
declared in one line. lpExistingFileName has to have a string holding a
path to an existing file you want to copy, lpNewFileName string has to
contain the new location of the file together with the filename, and
bFailIfExists controls how the function will if the file you want to
copy exists in that new location. If bFailIfExists is set to true and
the file exists, the function will fail, if it is set to false, the
function will overwrite the existing file.
NOTE: strings used in this API cannot exceed MAX_PATH length (which is 256 for most win os). And remember, not only specify the path where to copy the file, but also provide the file name of the copied file.
Example: Copies test.txt in c:\ to d:\test\ folder:
Private Sub cmdDelete_Click()
Made By Laimonas Simutis. 2001. firstname.lastname@example.org