多谢各位,原代码为:
unit searchu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
procedure searchdirs(dir:string);
public
{ Public declarations }
published
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure searchjpg(jpgdir:string);
var bool:integer;
searchrec:tsearchrec;
begin
bool:=findfirst(jpgdir+'/*.jpg',faanyfile,searchrec);
if bool=0 then
begin
while bool=0do
begin
deletefile(jpgdir+'/'+searchrec.name);
bool:=findnext(searchrec);
end;
end;
end;
procedure searchdirs(dir:string);
var searchrec:tsearchrec;
bool1:integer;
dir0:string;
begin
bool1:=findfirst(dir+'/*',faanyfile,searchrec);
while bool1=0do
begin
if filegetattr(searchrec.name)=fadirectory then
begin
dir0:=extractfilepath(searchrec.name);
searchjpg(dir0);
searchdirs(dir0+'searchrec.name')
end;
bool1:=findnext(searchrec);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
searchdirs('c:/');
end;
end.
请指正!!