在指定目录中查找符合条件的文件?(50分)

S

sunylat

Unregistered / Unconfirmed
GUEST, unregistred user!
你好:
我想在指定目录中查找符合条件的文件,而且要根据文件名称中的几个连续的字,例如:
在c:/test目录中有很多文件,我就想找出文件名中包含”汉字“的文件,请问如何解决?谢谢!

祝心情愉快!
 
delphi5开发人员指南上,就有这个例子,完全符合你的要求,而且它还可以进行
对子目录,
找一个文件后,把文件名名取出来,再判断‘汉字’是否在这个字符串中!
 
procedure TForm1.Button1Click(Sender: TObject);

var
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;
 
同意zhm_good的
而且是多线程的应用
有信箱么
我给你发过去
 
laohe@163.com
 
laohe@163.com
发了两次
都给退回来了
 
顶部