如何遍历文件夹,获得文件夹文件名,并将这些文件名放到组合框下拉列表里?
解决方案 »
- 有没有字符串模糊匹配函数?
- 如何在delphi7中实现带有单元格CheckBox(附图)
- 定位问题(集)
- 菜鸟级问题
- Delphi中Handle 如何转换成可操作访问内存指针??
- 如何用SQL语句创建一个有小数字段的表,小数格式为两位小数,默认值为零(ACCESS数据库)?
- 看了很多用计算字段得到记录号的方法,但还是不明白,谁能给我一个实例。
- CSDN真是的,速度慢就不说了,现在居然不能给分了!
- 究竟该如何对时间型的字段做日期的动态查询??
- 请问如何知道哪些对象联接到当前的TPopupMenu,请赐教?!!!!
- 请问如何把工程的Unit1.pas保存到子目录下?
- AdvStringGrid 与左 右 上 下 键
var
SearchRec: TSearchRec;
Path: string;
Attr: Integer;
Found: Integer;
begin
Path := ExtractFilePath(ParamStr(0)) + '*.ini';//设定要显示的路径
Attr := faAnyFile;
Found := FindFirst(Path, Attr, SearchRec);//查找文件
while Found = 0 do
begin
Cmbox1.Items.Add(Copy(SearchRec.Name, 1, length(SearchRec.Name) - 4));
Found := FindNext(SearchRec);
end;
FindClose(SearchRec);//停止查找
CmBox1.ItemIndex := 0;
end;
//=====================================================================
// 函数名称: FindAllFiles
// 功能描述: 找指定目录下的所有文件,包括子目录
// 参 数: APath : 路径名称
// APropty : 属性名称(*.* | *.txt)
// AFiles : 文件列表
// IsAddPath: 是否增加路径
// 作者:
// 时间:
// 返 回 值:
// 说 明:
//=====================================================================
procedure FindAllFiles(const APath: string; AFiles: TStrings;
const APropty: String = '*.*'; IsAddPath: Boolean = False);
var
FS: TSearchRec;
FPath: String;
AddPath: string;
begin
FPath := IncludeTrailingPathDelimiter(APath);
AddPath := IfThen(IsAddPath, FPath, '');
if FindFirst(FPath + APropty, faAnyFile, FS) = 0 then
begin
repeat
if (FS.Name <> '.') and (FS.Name <> '..') then
if ((FS.Attr and faDirectory) = faDirectory) then
FindAllFiles(FPath + FS.Name, AFiles, APropty, IsAddPath)
else
AFiles.Add(AddPath + FS.Name);
until FindNext(FS) <> 0;
SysUtils.FindClose(FS);
end;
end;调用方法FindAllFiles('c:\tmp', ComboBox1.Items, '*.*', true);