Following information comes from MSDN:rename, _wrename Rename a file or directory.int rename( const char *oldname, const char *newname ); int _wrename( const wchar_t *oldname, const wchar_t *newname );
SHFILEOPSTRUCT Contains information that the SHFileOperation function uses to perform file operations. typedef struct _SHFILEOPSTRUCT{ HWND hwnd; UINT wFunc; LPCTSTR pFrom; LPCTSTR pTo; FILEOP_FLAGS fFlags; BOOL fAnyOperationsAborted; LPVOID hNameMappings; LPCTSTR lpszProgressTitle; } SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
Members hwnd Window handle to the dialog box to display information about the status of the file operation. wFunc Value that indicates which operation to perform. This member can be one of the following values: FO_COPY Copy the files specified in the pFrom member to the location specified in the pTo member. FO_DELETE Delete the files specified in pFrom. FO_MOVE Move the files specified in pFrom to the location specified in pTo. FO_RENAME Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead.
delete old 文件夹。
MoveFile("Source.file", "Destination.file");
反问:如果这个文件夹中内容很多(100G),你还这么做么?
Rename a file or directory.int rename( const char *oldname, const char *newname );
int _wrename( const wchar_t *oldname, const wchar_t *newname );
Contains information that the SHFileOperation function uses to perform file operations. typedef struct _SHFILEOPSTRUCT{
HWND hwnd;
UINT wFunc;
LPCTSTR pFrom;
LPCTSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCTSTR lpszProgressTitle;
} SHFILEOPSTRUCT, *LPSHFILEOPSTRUCT;
Members
hwnd
Window handle to the dialog box to display information about the status of the file operation.
wFunc
Value that indicates which operation to perform. This member can be one of the following values:
FO_COPY
Copy the files specified in the pFrom member to the location specified in the pTo member.
FO_DELETE
Delete the files specified in pFrom.
FO_MOVE
Move the files specified in pFrom to the location specified in pTo.
FO_RENAME
Rename the file specified in pFrom. You cannot use this flag to rename multiple files with a single function call. Use FO_MOVE instead.