我正在使用以下代码来获取文件和文件夹的列表。我似乎无法让列表包含隐藏文件和文件夹。
procedure GetAllSubFolders(sPath: String; Listbox: TListbox);
var
Path: String;
Rec: TSearchRec;
begin
try
Path := IncludeTrailingBackslash(sPath);
if FindFirst(Path + '*.*', faDirectory, Rec) = 0 then
try
repeat
if (Rec.Name <> '.') and (Rec.Name <> '..') then
begin
if (ExtractFileExt(Path + Rec.Name) <> '') And (Directoryexists(Path + Rec.Name + '\') = False) then
Begin
Listbox.Items.Add(Path+Rec.Name);
End;
GetAllSubFolders(Path + Rec.Name, Listbox);
end;
until FindNext(Rec) <> 0;
finally
FindClose(Rec);
end;
except
on e: Exception do
Showmessage('Err : TForm1.GetAllSubFolders - ' + e.Message);
end;
end;