如何统计某个目录下的制定类型的文件数量
解决方案 »
- 请问这个语句该怎么写
- 高分求救:使用indytcpserver报错,是怎么回事?在线等待结帖
- help
- 小软件外包,很简单!
- 简单问题:为什么adoquery这样不能更新数据??(在线)
- 考研,csdn的朋友们给我指点一下!
- 变量和过程、函数的作用域!!!用DELPHI半年了,这些还不明白!!!!!!!!
- 为什么我的程序在有些机上提示“ADO找不到提供者”
- 近日下载了一个打字软件,DELPHI做的,只有一个执行文件和几个MDB、DBF。。
- 以DELPHI语言为前端,数据存贮在ORACLE中,但DELPHI为什么不能将数值型的数据写入?
- 文件操作
- 读过李维写的 Delphi 5.X ADO_MTS_COM+高级程序设计篇 第9章的请进。。。。。。
sr: TSearchRec;
FileAttrs: Integer;
begin
StringGrid1.RowCount := 1;
if CheckBox1.Checked then
FileAttrs := faReadOnly
else
FileAttrs := 0;
if CheckBox2.Checked then
FileAttrs := FileAttrs + faHidden;
if CheckBox3.Checked then
FileAttrs := FileAttrs + faSysFile;
if CheckBox4.Checked then
FileAttrs := FileAttrs + faVolumeID;
if CheckBox5.Checked then FileAttrs := FileAttrs + faDirectory;
if CheckBox6.Checked then
FileAttrs := FileAttrs + faArchive;
if CheckBox7.Checked then FileAttrs := FileAttrs + faAnyFile; with StringGrid1 do
begin
RowCount := 0; if FindFirst(Edit1.Text, FileAttrs, sr) = 0 then begin
repeat
if (sr.Attr and FileAttrs) = sr.Attr then
begin
RowCount := RowCount + 1;
Cells[1,RowCount-1] := sr.Name;
Cells[2,RowCount-1] := IntToStr(sr.Size);
end;
until FindNext(sr) <> 0;
FindClose(sr);
end;
end;
end;
begin
FileSeacher('c:\*.exe');
end;procedure TForm1.FileSeacher(FindStr: string);
var
Sr: TSearchrec;
FileAttrs: Integer;
i : integer;
begin
i := 0;
FileAttrs := faanyfile; if FindFirst(FindStr,FileAttrs,Sr) = 0 then
begin
repeat
if (Sr.Attr and FileAttrs) = Sr.Attr then
begin
i := i+1;
end;
until findnext(Sr) <>0 ;
findclose(Sr);
end;
showmessage(inttostr(i));end;
其中FileAttrs 可以是
faSysFile System files
faVolumeID Volume ID files
faDirectory Directory files
faArchive Archive files
faAnyFile Any file