Kernel32CopyFileEx Method
Copies an existing file to a new file, notifying the application of its progress through a callback function.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static bool CopyFileEx(
string existingFileName,
string newFileName,
DelegatesCopyProgressRoutine progressRoutine,
IntPtr data,
ref bool refCancel,
CopyFileFlags copyFlags
)
<DllImportAttribute("Kernel32.dll", CharSet := CharSet.Unicode, SetLastError := true>]
Public Shared Function CopyFileEx (
existingFileName As String,
newFileName As String,
progressRoutine As DelegatesCopyProgressRoutine,
data As IntPtr,
ByRef refCancel As Boolean,
copyFlags As CopyFileFlags
) As Boolean
Dim existingFileName As String
Dim newFileName As String
Dim progressRoutine As DelegatesCopyProgressRoutine
Dim data As IntPtr
Dim refCancel As Boolean
Dim copyFlags As CopyFileFlags
Dim returnValue As Boolean
returnValue = Kernel32.CopyFileEx(existingFileName,
newFileName, progressRoutine, data,
refCancel, copyFlags)
public:
[DllImportAttribute(L"Kernel32.dll", CharSet = CharSet::Unicode, SetLastError = true)]
static bool CopyFileEx(
String^ existingFileName,
String^ newFileName,
DelegatesCopyProgressRoutine^ progressRoutine,
IntPtr data,
bool% refCancel,
CopyFileFlags copyFlags
)
[<DllImportAttribute("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)>]
static member CopyFileEx :
existingFileName : string *
newFileName : string *
progressRoutine : DelegatesCopyProgressRoutine *
data : IntPtr *
refCancel : bool byref *
copyFlags : CopyFileFlags -> bool
No code example is currently available or this language may not be supported.
- existingFileName String
-
The name of an existing file.
- newFileName String
-
The name of the new file.
- progressRoutine DelegatesCopyProgressRoutine
-
The address of a callback function of type LPPROGRESS_ROUTINE that is called
each time another portion of the file has been copied.
This parameter can be NULL.
- data IntPtr
-
The argument to be passed to the callback function.
- refCancel Boolean
-
If this flag is set to TRUE during the copy operation, the operation is canceled.
Otherwise, the copy operation will continue to completion.
- copyFlags CopyFileFlags
-
Flags that specify how the file is to be copied.
Boolean
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
To get extended error information call
GetLastWin32Error.
If
progressRoutine returns PROGRESS_CANCEL due to the user canceling the operation,
CopyFileEx(String, String, DelegatesCopyProgressRoutine, IntPtr, Boolean, CopyFileFlags) will return zero and
GetLastWin32Error will
return
ERROR_REQUEST_ABORTED.
In this case, the partially copied destination file is deleted.
If
progressRoutine returns PROGRESS_STOP due to the user stopping the operation,
CopyFileEx(String, String, DelegatesCopyProgressRoutine, IntPtr, Boolean, CopyFileFlags) will return zero and
GetLastWin32Error will
return
ERROR_REQUEST_ABORTED.
In this case, the partially copied destination file is left intact.