procedure FunFindFile(aPath, aFileName: String); //p为路径字符,带‘\’
var
SR: TSearchRec;
SearchStr: String;
begin
{$WARN SYMBOL_PLATFORM OFF}
if FindFirst(aPath + aFileName, faArchive, SR) = 0 then
try
repeat
SearchStr := aPath + SR.Name;
//Synchronize(ShowFile);
until (FindNext(SR) <> 0) ;
finally
SysUtils.FindClose(SR);
end;
end;procedure FunFindAll(S: string); //s为路径字符,带‘\’
var
SR: TSearchRec;
begin
if FindFirst(S + '*.*', faDirectory, SR) = 0 then
try
repeat
if ((SR.Attr and faDirectory) <> 0) and (SR.Name[1] <> '.') then
begin
FunFindFile(S , SR.Name + '\');
FunFindAll(S + SR.Name + '\');
end;
until (FindNext(SR) <> 0) ;
finally
SysUtils.FindClose(SR);
end;
end;
var
SR: TSearchRec;
SearchStr: String;
begin
{$WARN SYMBOL_PLATFORM OFF}
if FindFirst(aPath + aFileName, faArchive, SR) = 0 then
try
repeat
SearchStr := aPath + SR.Name;
//Synchronize(ShowFile);
until (FindNext(SR) <> 0) ;
finally
SysUtils.FindClose(SR);
end;
end;procedure FunFindAll(S: string); //s为路径字符,带‘\’
var
SR: TSearchRec;
begin
if FindFirst(S + '*.*', faDirectory, SR) = 0 then
try
repeat
if ((SR.Attr and faDirectory) <> 0) and (SR.Name[1] <> '.') then
begin
FunFindFile(S , SR.Name + '\');
FunFindAll(S + SR.Name + '\');
end;
until (FindNext(SR) <> 0) ;
finally
SysUtils.FindClose(SR);
end;
end;
ShellListView1: TShellListView;
方案2:用一个不可见的FileListBox控件,指定其Directory,就可以通过其Items来得到文件列表。