Not a Member Yet,
Click here to Register

ID: 128
Viewed: 2875
Added: Apr 28, 2002
Version:
Snippet uploaded by: snippet
Written By: unknown
Demo: Sorry, no demo



User Rated at: 4 Stars4 Stars4 Stars4 Stars
Rate This:

Thank you for your vote. Please wait...

It appears you already voted for this snippet

It appears your vote value was empty

Windows API Guide: CopyFile Function Platforms: Win 32s, Win 95/98, Win NT CopyFile copies a file from one location to another, just like copying a file in Windows Explorer or in some other way. Depending on the value for bFailIfExists, it will either overwrite the target file if it already exists, or will fail. The function retuns 1 if successful, or 0 if an error occured. lpExistingFileNameThe source file; i.e., the file to copy from. lpNewFileNameThe target file; i.e., the new file to create that will be the copy. bFailIfExistsIf 0, the function will overwrite lpNewFileName if it already exists. If non-zero, the function will instead fail.

Highlight all by clicking in box
<!---Declaration--->
none

Highlight All
<!---Code--->
'Example:
' Copy the file C:MyStufftemp.txt to C:Junkbuffer.txt.
' Do not overwrite C:Junkbuffer.txt if it already exists.
Dim retval As Long ' return value
' copy the file
retval = CopyFile("C:MyStufftemp.txt", "C:Junkbuffer.txt", 1)
If retval = 0 Then ' failure
Debug.Print "Copy failed -- C:Junkbuffer.txt already exists.
Else ' success
Debug.Print "Copy succeeded."
End If;


Subject: Missing Declaration
[ Reply ]
Comment By: Felix on 02nd of September 2005 10:49 PM

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


Please completely fill out the form below if you want to review this snippet. All reviews are subject to validation.


Replying to a Comment...


Adding your comment. Please wait...

Thanks for adding your comment!. After further review it will be added.

There was a problem adding your comment. Please try again.

Please complete all the fields in the form before sending.

© 2002 - 2024 snippetlibrary.com All Rights Reserved. Conditions
Do NOT follow this link or you will be banned from the site!