Hallo everybody!
I have downloaded the file in the link down below.
http://www.bsdg.org/SWAG/DIRS/0006.PAS.html
I use dev-pascal 1.9.2 as ide for my pascal programming. I have made a little modifications of the file.
It works perfect if I use it as a "single" file, not in a project. But if I use it in a project it only searches the first
and only the first directory, and deletes files from it. When it tries to remove a directory which is empty it can't and gives a runtime 5 error and stops.
Do anyone have any idea why the error occurs and why the program in a project can't remove directories?
here is the code :
Program deleteDirectory;
uses Dos;
Procedure ClrDir ( path : pathStr );
Var FileInfo : searchRec;
f : File;
path2 : pathStr;
s : String;
begin FindFirst ( path + '\*.*', AnyFile, FileInfo );
While DosError = 0 Do
begin if (FileInfo.Name[1] <> '.') and (FileInfo.attr <> VolumeId) then
if ( (FileInfo.Attr and Directory) = Directory ) then
begin Path2 := Path + '\' + FileInfo.Name;
ClrDir ( path2 );
end
else
if ((FileInfo.Attr and VolumeID) <> VolumeID) then begin
 
; Assign ( f, path + '\' + FileInfo.Name );
Erase ( f );
end;
FindNext ( FileInfo );
end;
if (DosError = 18) and not ((Length(path) = 2)
and ( path[2] = ':')) then
RmDir ( path );
end;
begin
ClrDir('c:\temp\somedirectory');
end.
Martin
Online Virus Test: Scanna din computer GRATIS online-scanna
_______________________________________________ fpc-other maillist - [EMAIL PROTECTED] http://lists.freepascal.org/mailman/listinfo/fpc-other
