请问,怎样移动文件夹?

fly880 2005-11-14 11:32:05

我现在有文件夹A,A的下面有很多子文件夹(如,B,C,D,E,F;
我现在要在A的下面再新建立一个文件夹H,那怎样才能把A目录下的B、C、D这些文件夹移动H中去?

CSDN中说MoveFile函数可以移动文件和文件夹,可我用程序运行发现MoveFile函数只能移动文件,而没法移动文件夹,请问您有什么高招么?

谢谢各位!
...全文
365 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
打雷啦的专栏 2005-11-16
  • 打赏
  • 举报
回复
WINSHELLAPI int WINAPI SHFileOperation(
LPSHFILEOPSTRUCT lpFileOp
);

就这一个参数,以下是这个结构体的定义,看一下,应该简单的.
SHFILEOPSTRUCT


typedef struct _SHFILEOPSTRUCT{
HWND hwnd;
UINT wFunc;
LPCSTR pFrom;
LPCSTR pTo;
FILEOP_FLAGS fFlags;
BOOL fAnyOperationsAborted;
LPVOID hNameMappings;
LPCSTR lpszProgressTitle;
} SHFILEOPSTRUCT, FAR *LPSHFILEOPSTRUCT;

Contains information that the SHFileOperation function uses to perform file operations.

hwnd
Window handle to the dialog box to display information about the status of the file operation.
wFunc
Operation to perform. This member can be one of the following values: FO_COPY Copies the files specified in the pFrom member to the location specified in the pTo member.
FO_DELET Deletes the files specified in pFrom. (pTo is ignored.)
FO_MOVE Moves the files specified in pFrom to the location specified in pTo.
FO_RENAME Renames the files specified in pFrom.

pFrom
Address of a buffer to specify one or more source file names. Multiple names must be null-separated. The list of names must be double null-terminated.
pTo
Address of a buffer to contain the name of the destination file or directory. The buffer can contain multiple destination file names if the fFlags member specifies FOF_MULTIDESTFILES. Multiple names must be null-separated. The list of names must be double null-terminated.
fFlags
Flags that control the file operation. This member can be a combination of the following flags: FOF_ALLOWUNDO Preserve Undo information, if possible. If pFrom does not contain fully qualified path and filenames, this flag is ignored.
FOF_CONFIRMMOUSE Not currently implemented.
FOF_FILESONLY Perform the operation on files only if a wildcard file name (*.*) is specified.
FOF_MULTIDESTFILES The pTo member specifies multiple destination files (one for each source file) rather than one directory where all source files are to be deposited.
FOF_NOCONFIRMATION Respond with Yes to All for any dialog box that is displayed.
FOF_NOCONFIRMMKDIR Does not confirm the creation of a new directory if the operation requires one to be created.
FOF_NOCOPYSECURITYATTRIBS Version 4.71. Microsoft® Windows NT® only. The security attributes of the file will not be copied.
FOF_NOERRORUI No user interface will be displayed if an error occurs.
FOF_RENAMEONCOLLISION Give the file being operated on a new name in a move, copy, or rename operation if a file with the target name already exists.
FOF_SILENT Does not display a progress dialog box.
FOF_SIMPLEPROGRESS Displays a progress dialog box but does not show the file names.
FOF_WANTMAPPINGHANDLE If FOF_RENAMEONCOLLISION is specified, the hNameMappings member will be filled in if any files were renamed.

fAnyOperationsAborted
Value that receives TRUE if the user aborted any file operations before they were completed, or FALSE otherwise.
hNameMappings
Handle to a file name mapping object that contains an array of SHNAMEMAPPING structures. Each structure contains the old and new path names for each file that was moved, copied, or renamed. This member is used only if the fFlags member includes the FOF_WANTMAPPINGHANDLE flag. The handle must be freed by using the SHFreeNameMappings function.
lpszProgressTitle
Address of a string to use as the title of a progress dialog box. This member is used only if fFlags includes the FOF_SIMPLEPROGRESS flag.
If the pFrom or pTo members are unqualified names, the current directories are taken from the global current drive and directory settings as managed by theGetCurrentDirectory andSetCurrentDirectory functions.


--------------------------------------------------------------------------------

Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.
fly880 2005-11-15
  • 打赏
  • 举报
回复
用SHFileOperation具体怎么操作呢?请问,可以给个例子么?
oyljerry 2005-11-14
  • 打赏
  • 举报
回复
可以通过命令行来移动
manboo 2005-11-14
  • 打赏
  • 举报
回复
Shell Move it!
打雷啦的专栏 2005-11-14
  • 打赏
  • 举报
回复
使用SHFileOperation这个API功能比较强,可以复制文件夹,不需要遍历.
ming6424 2005-11-14
  • 打赏
  • 举报
回复
先 新建
再 复制
最后再删除
菲斯可儿 2005-11-14
  • 打赏
  • 举报
回复
要自己遍历的。

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧