简单问题,怎样拷贝多个文件夹到指定路径?
入门级的菜鸟请教各位,怎样拷贝多个文件夹到指定路径?需要用到什么函数?
问题点数:20、回复次数:9Top
1 楼darkwood(堕落天使)回复于 2001-02-12 00:00:00 得分 0
怎么,不屑一顾吗?Top
2 楼songhtao(三十年孤独)回复于 2001-02-12 10:23:00 得分 5
没有拷贝文件夹的函数,如非要这样做的话有两种解决方法:
1.用Dos命令程序中需包含:#include <stdlib.h>预处理指令。
用:int system(const char *command);
command是Dos拷贝目录命令:copy a:\file b:\file /s。
缺点:用了Dos命令,程序可移植性下降。
2.自己编函数实现。提示要用到
BOOL CopyFile(
LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
Api 编程接口 。Top
3 楼VirusHuo()回复于 2001-02-12 13:44:00 得分 5
用FindFile 遍历目录,然后用CopyFile拷贝
或是先把一个目录里面所有的文件名都装入一TStringList,然后一个个的copyTop
4 楼zzroom(徐子陵)回复于 2001-02-12 22:55:00 得分 0
1、先用FindFile 遍历目录,然后用CopyFile拷贝.
2、先把一个目录里面所有的文件名都装入一TStringList,然后逐个copy. Top
5 楼darkwood(堕落天使)回复于 2001-02-12 23:48:00 得分 0
谢谢各位的支持,不过怎么会有雷同卷?!
Top
6 楼YuHao()回复于 2001-02-12 23:53:00 得分 0
怎么没有人建议用SHFileOperation啊,这个函数功能很强大的Top
7 楼Sachow(SC)回复于 2001-02-13 17:46:00 得分 10
不用SHFileOperation真是自找麻烦。
//---------------------------------------------------------------------------
void __fastcall TForm1::Copy_dir(AnsiString Source, AnsiString Target)
{
SHFILEOPSTRUCT OpStruc;
{
OpStruc.hwnd = Handle;
OpStruc.wFunc = FO_COPY; //FO_COPY, FO_MOVE, FO_DELETE
OpStruc.fFlags = FOF_SIMPLEPROGRESS;
OpStruc.pFrom = Source.c_str();
OpStruc.pTo = Target.c_str();
OpStruc.lpszProgressTitle = "正在复制文件……";
}
SHFileOperation(&OpStruc);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Copy_dir("E:\\西部大开发","C:\\西部大开发");
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
ShellAbout(Handle,"Shell About 演示","本程序演示了ShellAbout 对话框,此对话框 是Windows API提供的。",NULL);
}
//---------------------------------------------------------------------------
Top
8 楼Sunny_Yirui(雪飘飘)回复于 2001-02-14 09:10:00 得分 0
厉害!!Top
9 楼darkwood(堕落天使)回复于 2001-02-16 00:27:00 得分 0
谢了各位,加分!!!!!!!!Top




