Delphi——FindFirst学习
来源:互联网 发布:怎么查看淘宝卖家电话 编辑:程序博客网 时间:2024/05/29 18:55
FindFirst在SysUtils中声明 原型为
Fucntion FindFirst(const Path:String;Attr:Integer;Var F:TSearchRec):Integer;
描述:
从指定的目录中搜索第一个给定属性文件实例
返回结果保存到参数F中,F参数是一个文件结构包含文件信息
成功返回0,否则返回错误代码
参数Path:包含路径和搜索模糊文件名,包括通配符: './text/*.*'搜索test目录下的全部文件
参数Attr:指定文件属性类型
faReadOnly:只读文件
faHidden:隐藏文件
faSysFile:系统文件
faVolumeID:卷标文件
faDirectory:目录文件
faArchive:归档文件//压缩文件
faAnyFile:任何文件
Attr可以通过组合使用 faReadOnly+faSysFile
注意:
使用FindFist是要分配内存的使用完之后必须用FindClose关闭
一些属性只能在特定的平台上使用 faVolumeID和faArchivei不能在Unix和mac上使用
//遍历文件夹下所有文件function TForm1.GetFileList(ASourFile: string): TStringList;var sour_path,sour_file: string; TmpList:TStringList; FileRec:TSearchrec;begin sour_path:=ExtractFilePath(ASourFile); sour_file:=ExtractFileName(ASourFile); TmpList:=TStringList.Create; TmpList.Clear; if DirectoryExists(sour_path) then begin if FindFirst(sour_path+sour_file,faAnyfile,FileRec) = 0 then repeat if ((FileRec.Attr and faDirectory) = 0) then begin TmpList.Add(sour_path+FileRec.Name); end; until FindNext(FileRec)<>0; SysUtils.FindClose(FileRec); end; result := TmpList;end;
- Delphi——FindFirst学习
- Delphi——FindFirst学习
- Delphi——FindFirst学习
- DELPHI - FindFirst查找文件
- delphi下文件查找findfirst
- FindFirst
- findfirst, findnext
- findfirst findnext
- Delphi学习日记——第二课
- Delphi学习笔记二——数据类型
- Delphi学习笔记四——语句
- Delphi学习笔记五——方法
- Delphi学习笔记二——数据类型
- Delphi学习笔记四——语句
- Delphi学习笔记五——方法
- delphi学习——知识点总结
- Delphi的学习笔记——类
- Delphi学习笔记——方法
- adb server is out of date. killing...
- 【Qt官方视频码农】Qt_03-Intro_to_GUI_programming
- 'release' is unavailable: not available in automatic reference counting mode..
- java.lang.RuntimeException: Invalid action class configuration that references an unknown class name
- oracle开机自动重启配置
- Delphi——FindFirst学习
- UltraEdit 删除程序前行号
- premake版解决方案小工具
- Codeforces Round #204 (Div. 1) C Jeff and Brackets dp+矩阵加速
- Redesign Your App for iOS 7 之 页面布局
- dxva详解
- JS控制表单提交
- Makefile中的$@, $^, $< , $?, $%, $+, $*
- HTTP请求返回状态码详解