I want to make a program that lists files contained in a certain directory. I want to list the file and only the file, not the folders that is on this directory, too. How can I do this in Pascal? If in PHP, there is a function named "isDir", which return true if the parameter specified is a directory(folder). Using this function, I could check whether the "path" I'm using is a file or a folder.
Now, I am using the FindFirst and FindNext procedure to get all files/folders in the directory.
var F: SearchRec
while DosError=0 do begin
Try the following
while DosError=0 do begin if ((F.attr and faDirectory) <> faDirectory) then writeln(F.Name); FindNext(F); end;
Sorry my Pascal is a bit rusty
Basically the object returned by FindFirst/FindNext contains an ATTR property which indicated the type of file it is.
Also, at the end of your loop, be sure to add a FindClose() call to free the memory
File attribute constants