使用MoveFile或者MoveFileEx,也可以适用与文件夹MoveFileThe MoveFile function moves an existing file or a directory, including its children.To specify how to move the file, use the MoveFileEx function.
BOOL MoveFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName
);Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that names an existing file or directory.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.Windows Me/98/95: This string must not exceed MAX_PATH characters.
lpNewFileName
[in] 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.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.Windows Me/98/95: This string must not exceed MAX_PATH characters.
Return Values
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.Res
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.If a file is moved across volumes, MoveFile does not move the security descriptor with the file. The file will be assigned the default security descriptor in the destination directory.The MoveFile function coordinates its operation with the link tracking service, so link sources can be tracked as they are moved.
Windows Me/98/95: MoveFileW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
BOOL MoveFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName
);Parameters
lpExistingFileName
[in] Pointer to a null-terminated string that names an existing file or directory.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.Windows Me/98/95: This string must not exceed MAX_PATH characters.
lpNewFileName
[in] 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.
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.Windows Me/98/95: This string must not exceed MAX_PATH characters.
Return Values
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.Res
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.If a file is moved across volumes, MoveFile does not move the security descriptor with the file. The file will be assigned the default security descriptor in the destination directory.The MoveFile function coordinates its operation with the link tracking service, so link sources can be tracked as they are moved.
Windows Me/98/95: MoveFileW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.
解决方案 »
- winxp中用CFileDialog如何选择上万文档?
- 感觉WINVER这个宏是多余的,因为有了_WIN32_WINNT或者_WIN32_WINDOWS
- 求助,怎么给工程添加以CWnd为基类的派生类,然后重载OnEraseBkgnd函数
- 夜深了,再提一个问题..
- 如何让CScrollView子类的滚动条不显示?
- 哪里能下载《windows程序调试》(最好英文版)?
- 主 题: VC如何操作EXCEL和ACCESS数据库 UP有分哦
- microcp过来领分
- 如何防止下标越界或捕获下标越界异常
- 怎样再切分窗口中禁止用户拖动窗口的切分条,即禁止用户上下拖动改变两个View的大小
- 如何点击静态文本框调用颜色对话框?
- Sdh_DeviceDlg.cpp中如何调用DrawText()函数,里面的参数怎么写
CFileFinder cf;
cf.findfirst
每个找到的文件。cf.getfilename()
然后对此filename 用MoveFile