MoveFile

 

Description

Move a file to a new location.

Syntax

BOOL MoveFile( LPCSTR lpExistingFileName, LPCSTR lpNewFileName )

Parameters

lpExistingFileName
[input] Pointer to a null-terminated string that names an existing file or directory.
lpNewFileName
[input] Pointer to a null-terminated string that specifies the new name of a file or directory. The new name must not already exist. A new file may be on a different file system or drive. A new directory must be on the same drive.

Return

If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.

Examples

EX1

int    MoveFile_ex1()
{
    string strFine= GetAppPath(0) + "junk.ini"; 
    string strNewFilename = GetAppPath(0) + "themes\\" + "junk.ini";
    if (!MoveFile(strFine, strNewFilename)) 
    { 
        out_str("Couldn't MoveFile to other directory."); 
    }
    return 1;
}

Remark

The MoveFile function will move (rename) either a file or a directory (including 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.

See Also

CopyFile

header to Include

origin.h

Reference