MoveFile
The MoveFile
function moves a file or directory from one location to another.
Prototype
WIN32_WINUNIX.MoveFileW(
L"",
NULL
);
Description
This function is a Windows API function that allows you to rename a file or directory.
It's essentially a wrapper around the RenamedFile
function in
kernel32.dll
.
Parameters
-
L"
: A pointer to a null-terminated string specifying the path to the file or directory being moved." -
NULL
: This parameter is ignored.
Return Value
The function returns
TRUE
on success and
FALSE
on failure.
Error Codes
-
ERROR_PATH_NOT_FOUND
: The specified path does not exist. -
ERROR_ACCESS_DENIED
: The calling thread does not have sufficient privileges to move the file. -
ERROR_INVALID_PARAMETER
: An invalid parameter was passed to the function.
Example
#include
int main() {
// Example usage (simplified)
wchar_t filePath[] = L"C:\\MyFolder\\MyFile.txt";
if (MoveFileW(filePath, NULL) == FALSE) {
// Handle error
DWORD error = GetLastError();
// Further error handling...
}
return 0;
}