Share via


Moving and Copying Files and Directories (Windows Embedded CE 6.0)

1/6/2010

Use the CopyFile and the MoveFile functions to copy and move files, respectively. Both functions receive the name of the file to copy or move in their lpExistingFileName parameter, and they copy or move the file to the location that is described in their lpNewFileName parameter. CopyFile contains the bFailIfExists parameter, which enables you determine whether 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.

MoveFile can be used on directories, but not CreateFile. Using MoveFile on a directory moves all files and subdirectories in the directory.

The CopyFile and the MoveFile functions can copy and move a file in 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 from one volume to another, place the file in the object store as an intermediary step between the two volumes. You cannot move a directory from one volume to another.

You can also use the DeleteAndRenameFile function to move a file from one directory to another. Like the MoveFile function, DeleteAndRenameFile deletes a file after moving that file to another directory. However, you have the option of renaming the new version of the file.

See Also

Concepts

Creating, Deleting, and Maintaining Files
File System Operations