Get the code for all file names in the directory

Time:2019-10-7

First: Get the file of the specified folder

Copy codeThe code is as follows:
Procedure search file (path: string); // Note that there should be”after the path;
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+’*.*’,faAnyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>’.’) and (SearchRec.Name<>’..’)
and (SearchRec.Attr<>faDirectory) then
ListBox1.Add(SearchRec.Name);
found:=FindNext(SearchRec);
end;
FindClose(SearchRec);
end;

2: Get the files in the subdirectory of the directory

Copy codeThe code is as follows:
procedure SearchFile(path:string);
var
SearchRec:TSearchRec;
found:integer;
begin
found:=FindFirst(path+’*.*’,faAanyFile,SearchRec);
while found=0 do
begin
if (SearchRec.Name<>’.’) and (SearchRec.name<>’..) and
(SearchRec.Name=faDirectory) then
SearchFile(SearchRec.Name+’\’)
else
LisBox1.Add(SearchRec.Name);
found:=FindNext(SearchREc);
end;
FindClose(SearchRec);
end;

Recommended Today

Oracle (PLSQL) introduction 1

Oracle installation, user authorization, table operation, data type, DDL table, DML data. Next: Oracle introduction 2 Learning video: https://www.bilibili.com/video/BV1tJ411r7EC?p=15 Baidu cloud installation package is attached to the installation tutorial: https://blog.csdn.net/qq_ 40774525/article/details/79919057 Oracle Baidu cloud installation package: https://pan.baidu.com/s/1qVWwCUR37j2JxEecYbe5HQ Extraction code: 5abz After the Oracle service above is installed, open the client of SQL developer and the […]