土办法但是很有用,在程序里直接调用 DOS 命令:Shellexecute("open"....."start copy xxx\xxx\*.* xxx\xxx\*.*")简单吧?其实有些东西用命令行完全可以完成,为什么又何苦让自己写一个 "copy"命令呢?
解决方案 »
- delphi ado 事务 二表更新时只能更新一个表
- Tedit丢失焦点的问题 大家来看下。。。。。。。。
- 求spcomm发送rs485的16进制的报文,高分!
- 各位高人有没有delphi的语法参考手册啊,求!
- 关于MessageBox的问题
- Delphi中如何把所有字符操作改为Unicode型
- 开发B/S模式的项目,现在郁闷ing,不知道选择什么开发平台好啊? 帮帮忙,帮我参考参考
- 关于存储过程!
- 升级啦!! 谢谢弟兄们的支持!! 散分!!顺便问一个小问题(关于mozilla).
- delphi中用bde连接paradox。用query?
- 为什么使用ADOQuery1.LoadFromFile后再使用SQL语句返回结果集则出错?
- 如何显示HTML格式邮件
:P
TFunc = (COPY, MOVE, DELETE, RENAME);
{...}procedure TForm1.FileOperation(SrcFileName: PChar; DestFileName: PChar; AFunc: TFunc);
var
FileOp: SHFILEOPSTRUCT;
I: Integer;
begin
FileOp.Wnd := Self.Handle;
FileOp.pFrom := SrcFileName; // 可以是文件名或者目录名.
FileOp.pTo := DestFileName;
FileOp.fFlags := FOF_ALLOWUNDO;
FileOp.fAnyOperationsAborted := true;
FileOp.hNameMappings := nil;
FileOp.lpszProgressTitle := nil; case AFunc of
COPY: FileOp.wFunc := FO_COPY;
MOVE: FileOp.wFunc := FO_MOVE;
DELETE: FileOp.wFunc := FO_DELETE;
RENAME: FileOp.wFunc := FO_RENAME; //重命名已经由其他过程处理了.
end;
SHFileOperation(FileOp);
end;
procedure xcopy(source: string;dest:string);
var
sr: TSearchRec;
const
fileattrs=63;
begin
try
mkdir(dest);
except
end;
source:=source+'\*.*';
if FindFirst(source, fileattrs, sr) = 0 then
begin
if (sr.Name <>'.') and (sr.name<>'..') then
begin
if ((sr.attr and fadirectory)=fadirectory) then
xcopy(extractfilepath(source)+sr.name,dest+'\'+sr.name)
else
begin
copyfile(pchar(extractfilepath(source)+sr.name),pchar(dest+'\'+sr.name),false);
if strToFloat(form1.Edit3.Text)<>0 then
begin
dodo:=0;
Form1.Timer1.Enabled :=true;
while dodo=0 do
begin
Application.ProcessMessages;
end;
Form1.Timer1.Enabled :=false;
end;
end;
end;
while FindNext(sr) = 0 do
begin
if (sr.Name <>'.') and (sr.name<>'..') then
begin
if ((sr.attr and fadirectory)=fadirectory) then
xcopy(extractfilepath(source)+sr.name,dest+'\'+sr.name)
else
begin
copyfile(pchar(extractfilepath(source)+sr.name),pchar(dest+'\'+sr.name),false);
if strTofloat(form1.Edit3.Text)<>0 then
begin
dodo:=0;
Form1.Timer1.Enabled :=true;
while dodo=0 do
begin
Application.ProcessMessages;
end;
Form1.Timer1.Enabled :=false;
end;
end;
Application.ProcessMessages ;
end;
end;
FindClose(sr); end;end;
Foxpro好方便
{最后修改时间:17:07 2002-04-03 整理:刘红军}function TForm1.WinCOPY(File_name:string;File_name_S:string):string;
var
OpStruc:TSHFileOpStruct;
FromBuf,ToBuf:Array[0..128] of Char;
begin
FillChar(FromBuf,Sizeof(FromBuf),0);
FillChar(ToBuf,Sizeof(ToBuf),0);
//用0初始化FromBuf和ToBuf数组
StrPCopy(FromBuf,Pchar(File_name));
StrPCopy(ToBuf,Pchar(File_name_S));
//分别在 FromBuf和ToBuf数组中填入操作的源目录及目标目录
//开始填充OpStruc记录
with OpStruc do
begin
Wnd:=Handle;
wFunc:=FO_COPY;
//复制操作
pFrom:=@FromBuf;
pTo:=@ToBuf;
fFlags:=FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION;
fAnyOperationsAborted:=False;
hNameMappings:=nil;
lpszProgressTitle:=nil;
end;
OpStR:= SHFileOperation(OpStruc);
end;