The MoveFile function renames an existing file or a directory (including all its children).
BOOL MoveFile(
LPCTSTR lpExistingFileName, |
// address of name of the existing file |
LPCTSTR lpNewFileName |
// address of new name for the file |
); |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
The MoveFile function will move (rename) either a file or a directory (including all its children) either in the same directory or across directories. The one caveat is that the MoveFile function will fail on directory moves when the destination is on a different volume.