主题:[讨论]删除文件夹
procedure mydeletefile(s:string);
var
sr:tsearchrec;
begin
if findfirst(s+'\*.*',faanyfile,sr)=0 then
begin
if (sr.name<> '.')and(sr.name<>'..') then
begin
if sr.Attr=fadirectory then
begin
mydeletefile(s+'\'+sr.name);
end
else
deletefile(pchar(s+'\'+sr.name));
end;
while findnext(sr)=0 do
begin
if (sr.name<> '.')and(sr.name<>'..') then
if sr.Attr=fadirectory then
begin
mydeletefile(s+'\'+sr.name);
end
else
deletefile(pchar(s+'\'+sr.name));
end;
findclose(sr);
end;
end;
这样删除一个文件夹下的所有文件怎么删不掉呀,那里错了呀
var
sr:tsearchrec;
begin
if findfirst(s+'\*.*',faanyfile,sr)=0 then
begin
if (sr.name<> '.')and(sr.name<>'..') then
begin
if sr.Attr=fadirectory then
begin
mydeletefile(s+'\'+sr.name);
end
else
deletefile(pchar(s+'\'+sr.name));
end;
while findnext(sr)=0 do
begin
if (sr.name<> '.')and(sr.name<>'..') then
if sr.Attr=fadirectory then
begin
mydeletefile(s+'\'+sr.name);
end
else
deletefile(pchar(s+'\'+sr.name));
end;
findclose(sr);
end;
end;
这样删除一个文件夹下的所有文件怎么删不掉呀,那里错了呀