怎么才能把一个文件夹的东西复制到另一个文件夹里面呢?
我上网找了几个函数报错!我是初学者,不太懂这什么意思,麻烦帮帮!
Function TOpenPicFrm.Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean;
Var
Opstruc : TshFileOpStruct;
frombuf,tobuf: Array[0..128] of Char;
begin
FillChar(frombuf,Sizeof(frombuf),0);
FillChar(tobuf,Sizeof(tobuf),0);
StrPcopy(frombuf,SourceDir);
Case nLx of
1:
StrPcopy(tobuf,DestDir);
end;
With Opstruc Do
Begin
Wnd:=0;
Case nLx of
1: wFunc:=FO_COPY;
2: wFunc:=FO_DELETE;
Else wFunc:=FO_COPY;
end;
pFrom:=@frombuf;
pTo:=@tobuf;
fFlags:=FOF_NOCONFIRMATION;
fAnyOperationsAborted:=False;
hNameMappings:=Nil;
lpszProgressTitle:=Nil;
end;
try
ShFileOperation(OpStruc);
Result:=True;
except
Result:=False;
end;
end;
我上网找了几个函数报错!我是初学者,不太懂这什么意思,麻烦帮帮!
Function TOpenPicFrm.Copy_Dir(SourceDir,DestDir:String;nLx:Integer):Boolean;
Var
Opstruc : TshFileOpStruct;
frombuf,tobuf: Array[0..128] of Char;
begin
FillChar(frombuf,Sizeof(frombuf),0);
FillChar(tobuf,Sizeof(tobuf),0);
StrPcopy(frombuf,SourceDir);
Case nLx of
1:
StrPcopy(tobuf,DestDir);
end;
With Opstruc Do
Begin
Wnd:=0;
Case nLx of
1: wFunc:=FO_COPY;
2: wFunc:=FO_DELETE;
Else wFunc:=FO_COPY;
end;
pFrom:=@frombuf;
pTo:=@tobuf;
fFlags:=FOF_NOCONFIRMATION;
fAnyOperationsAborted:=False;
hNameMappings:=Nil;
lpszProgressTitle:=Nil;
end;
try
ShFileOperation(OpStruc);
Result:=True;
except
Result:=False;
end;
end;
[Error] FrmOpenPic.pas(38): Undeclared identifier: 'TshFileOpStruct'
function CopyDir(const SourceDir,DestDir: string): Boolean;
var
lpFileOp: TSHFileOpStruct;
begin
with lpFileOp do
begin
Wnd := Application.Handle;
wfunc := FO_COPY;
pFrom := pchar(SourceDir);
pTo := pchar(DestDir);
fFlags := FOF_ALLOWUNDO;
hNameMappings := nil;
lpszProgressTitle := nil;
fAnyOperationsAborted := false;
end;
Result := SHFileOperation(lpFileOp) = 0
end;