我想寫一個可以揾到program所在既Directory中既所有野,然後鏟晒佢既program.
但係RUN既時候就只係Delete到Files 同吉既Folder,有野係入面既FOLDER就鏟唔到,請問應該點改,又或者加D乜野呢?
以下係我一D code:
program main;
uses sysutils,crt,dos;
var t1: text;
root,dir,path,target: string;
b: byte;
found:searchrec;
key:char;
///////////////////////////////////////////////////////////////////////
procedure findanddel;
var f:text;
begin
findfirst('*.*',anyfile,found);
while (doserror = 0) do begin
assign(f,found.name);
{$I-}
erase(f);
{$I+}
if (ioresult <> 0) then begin end;
findnext(found);
end;
end;
///////////////////////////////////////////////////////////////////////
(* main body *)
begin
repeat
key:=readkey;
until ((key=#27) or (key=#13));
////////////////////////////////////////////////////////////////////////
if ((key=#13)) then { enter pressed }
begin
getdir(b,dir);
root:=dir;
findanddel;
findfirst('*.*',anyfile,found);
while (doserror = 0) do
begin
path:=(dir+'\'+found.name);
target:=found.name;
{$I-}
rmdir(target);
{$I+}
if ioresult<>0 then begin end;
findnext(found);
end; {while do end}
end; {if then end}
////////////////////////////////////////////////////////////////////////
end. {program end}