Platform SDK: Files and I/O |
The MoveFileWithProgress function moves a file or directory. MoveFileWithProgress is equivalent to the MoveFileEx function, except that MoveFileWithProgress allows you to provide a callback function that receives progress notifications.
BOOL MoveFileWithProgress( LPCTSTR lpExistingFileName, // file name LPCTSTR lpNewFileName, // new file name LPPROGRESS_ROUTINE lpProgressRoutine, // callback function LPVOID lpData, // parameter for callback DWORD dwFlags // move options );
Windows NT/2000: In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to nearly 32,000 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see File Name Conventions.
Windows 95/98: This string must not exceed MAX_PATH characters.
When moving a file, lpNewFileName can be on a different file system or drive. If lpNewFileName is on another drive, you must set the MOVEFILE_COPY_ALLOWED flag in dwFlags.
When moving a directory, lpExistingFileName and lpNewFileName must be on the same drive.
If dwFlags specifies MOVEFILE_DELAY_UNTIL_REBOOT, lpNewFileName can be NULL. In this case, MoveFileEx registers lpExistingFileName to be deleted when the system restarts. The function fails if it cannot access the registry to store the information about the delete operation. If lpExistingFileName refers to a directory, the system removes the directory at restart only if the directory is empty.
Value | Meaning |
---|---|
MOVEFILE_COPY_ALLOWED | If the file is to be moved to a different volume, the function simulates the move by using the CopyFile and DeleteFile functions.
This value cannot be used with MOVEFILE_DELAY_UNTIL_REBOOT. |
MOVEFILE_CREATE_HARDLINK | Reserved for future use. |
MOVEFILE_DELAY_UNTIL_REBOOT | The system does not move the file until the operating system is restarted. The system moves the file immediately after AUTOCHK is executed, but before creating any paging files. Consequently, this parameter enables the function to delete paging files from previous startups.
This value can only be used if the process is in the context of a user who belongs to the administrator group or the LocalSystem account. This value cannot be used with MOVEFILE_COPY_ALLOWED. |
MOVEFILE_FAIL_IF_NOT_TRACKABLE | The function fails if the source file is a link source, but the file cannot be tracked after the move. This situation can occur if the destination is a volume formatted with the FAT file system. |
MOVEFILE_REPLACE_EXISTING | If a file named lpNewFileName exists, the function replaces its contents with the contents of the lpExistingFileName file.
This value cannot be used if lpNewFileName or lpExistingFileName names a directory. |
MOVEFILE_WRITE_THROUGH | The function does not return until the file has actually been moved on the disk.
Setting this value guarantees that a move performed as a copy and delete operation is flushed to disk before the function returns. The flush occurs at the end of the copy operation. This value has no effect if MOVEFILE_DELAY_UNTIL_REBOOT is set. |
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 MoveFileWithProgress function coordinates its operation with the link tracking service, so link sources can be tracked as they are moved.
To delete or rename a file, you must have either delete permission on the file or delete child permission in the parent directory. If you set up a directory with all access except delete and delete child and the ACLs of new files are inherited, then you should be able to create a file without being able to delete it. However, you can then create a file, and you will get all the access you request on the handle returned to you at the time you create the file. If you requested delete permission at the time you created the file, you could delete or rename the file with that handle but not with any other.
Windows NT/2000: Requires Windows 2000.
Windows 95/98: Unsupported.
Header: Declared in Winbase.h; include Windows.h.
Library: Use Kernel32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows 2000.
File I/O Overview, File I/O Functions, CopyFileEx, CopyProgressRoutine, MoveFileEx