Can't delete directories
- From: jullape@xxxxxxxx (DC.)
- Date: 28 Apr 2005 08:23:39 -0700
Hi,
I'm trying to delete the directories and files below a given
directory, i have no problem deleting the files, but when i try to
delete the directories, it complains, getlastError says that there
could be any application using those directories. Is there any way to
force those directories to be deleted?, the code is like follows:
procedure DeleteAllFilesInDir(DirName:string);
var
DirInfo: TSearchRec;
DirInfoDir: TSearchRec;
r : Integer;
begin
r := FindFirst(DirName+'\*.*', FaAnyfile, DirInfo);
while r = 0 do
begin
DeleteFile(pChar(DirName+'\' + DirInfo.Name));
r := FindNext(DirInfo);
end;
SysUtils.FindClose(DirInfo);
SetCurrentDir(Dirname);
r := FindFirst('*', faDirectory, DirInfoDir);
while r = 0 do begin
if (DirInfoDir.name<>'.') and (DirInfoDir.name<>'..') then
DeleteAllFilesInDir(pChar(DirName+'\' +
DirInfoDir.Name));
r := FindNext(DirInfoDir);
end;
if (not RemoveDir(dirname)) and (not m_avisado) then begin
ShowMessageFmt('TestDir removed failure with error
%d',[GetlastError]);
m_avisado := true;
end;
SysUtils.FindClose(DirInfoDir);
end;
Thanks in advance.
.
- Follow-Ups:
- Re: Can't delete directories
- From: Bruce Roberts
- Re: Can't delete directories
- From: Kent Briggs
- Re: Can't delete directories
- From: Tom de Neef
- Re: Can't delete directories
- Prev by Date: Re: TBitmap - how to copy an "object"
- Next by Date: Re: Can't delete directories
- Previous by thread: TBitmap - how to copy an "object"
- Next by thread: Re: Can't delete directories
- Index(es):