西西最近在學Delphi,哈,沒什么基礎,就想著在網上找點現成的代碼,結果找了好多都調試不出來,可能是代碼有點老了,或者跟XE2不兼容。
今早晨找高手艾老師請教了,結果他劈理帕里幾下就弄好了,汗顏?。。。ㄒ幌麓a在Delphi7里可能不兼容,XE2調試的。)
需要加上uses
Types, IOUtils
procedure TForm1.Button1Click(Sender: TObject);
var
files: TStringDynArray;
str: string;
begin
files := TDirectory.GetFiles('c:\', '*.log', TSearchOption.soAllDirectories);
Memo1.Clear;
Memo1.Lines.BeginUpdate;
for str in files do
begin
memo1.Lines.Add(str);
DeleteFile(str);
CopyFile(PChar(str), PChar('C:\Users\Administrator\Desktop\新建文件夾 (3)\' + ExtractFileName(str)), False);
end;
Memo1.Lines.EndUpdate;
end;
哈,以上代碼也是從萬一老師的博客找的。感謝前輩高手萬一老師,學delphi,這個http://www.cnblogs.com/del 可不能少,萬一老師的博客。也很謝謝艾老濕 哦。