[RED] uses ...,FileCtrl,ShellApi; [/RED]
[BLUE]
procedure TForm1.Button1Click(Sender: TObject);
begin
if CopyDirFileToA('C:/WINDOWS','A:/') then
MessageBox(Handle,'文件复制成功!','提示框',MB_OK+MB_ICONINFORMATION)
else
MessageBox(Handle,'文件复制成功!','提示框',MB_OK+MB_ICONWARNING);
end;
function TForm1.CopyDirFileToA(SourceDir, DestDrive: String): Boolean;
var
FileListBox: TFileListBox;
I:Integer;
begin
Result:=False;
if Trim(SourceDir)='' then exit;
if Trim(DestDrive)='' then exit;
FileListBox:=TFileListBox.Create(Self);
FileListBox.Parent:=Self;
FileListBox.Directory:=Trim(SourceDir);
For I:=0 to FileListBox.Items.Count-1 do
begin
try
CopyFile(Pchar(SourceDir+'/'+FileListBox.Items.Strings
),Pchar(DestDrive+FileListBox.Items.Strings),True);
except
Result:=False;
end;
end;
FileListBox.Free;
end;
[/BLUE][]