Moving and Copying Files and Directories

Use the CopyFile and MoveFile functions to copy and move files, respectively. Both functions receive the name of the file to copy or move in their respective lpExistingFileName parameters and copy or move the file to the location described in their respective lpNewFileName parameters. CopyFile contains the bFailIfExists parameter, which lets you determine if you want CopyFile to copy over a file if a version of the file exists in the target directory. MoveFile does not have a corresponding pFailIfExists parameter; instead, MoveFile automatically fails if the file already exists in the target directory. You can use both CopyFile and MoveFile on directories. Using MoveFile on a directory moves all of the files and subdirectories within that directory.

CopyFile and MoveFile can copy and move a file within the object store, from a mounted drive to the object store, or from the object store to a mounted drive. To copy or move a file or directory from one volume to another, place the file or directory in the object store as an intermediary step between the two volumes.

You can also use the DeleteAndRenameFile function to move a file from one directory to another. Like MoveFile, DeleteAndRenameFile deletes a file after moving that file to another directory. However, you have the option of renaming the new version of the file. This function works only on RAM-based files.