当前位置:主页>销售管理软件> 列表

如何判断文件名是否有01_20的字符? 找进销存详细设计

仓库管理软件版1楼: 例如,c:/data/20060120/目录下有文件
01_2001
01_2011
02_0512
只要文件名中含有01_20就把赋值为true
我用FileExists(DirName+''/''+FileName)来判断。
但是这样只有指定文件名FileName:=''01_2001''才能判断是否存在,怎样才能达到如FileName:=''01_20''来判断,或FileName:=''01_20*''

不会又要用遍历吧

2楼: 因为目录里文件多达千个,所以我想FileExists效率高点 如进销存详细设计

3楼: 要知道文件是什么类型去里边判断

4楼: 文件名没有后缀名的

5楼: 用FindFirst和FindNext函数查找出该目录下所有“01_20*” 这两个函数支持通配符的。

6楼: 谢谢。
Found := FindFirst(''c:\01_20*'',faAnyFile,SearchRec);

请问SearchRec是一个数组还是什么呢?
如果找到有01_2001,01_2011两个文件,哪SearchRec会怎么表现他们?

仓库管理软件版7楼: if pos(''01_02'',''c:\ajf\j01_02fff.jpg'')>0 then
showmessage(''有這個字符'');

8楼: 我觉得你可以先把01_20替换成特殊的字符,然后只要存在这个特殊字符就可以了

9楼: FindFirst searches the directory specified by Path for the first file that matches the file name implied by Path and the attributes specified by the Attr parameter. The result is returned in the F parameter. Use the fields of this search record to extract the information needed. FindFirst returns 0 if a file was successfully located, otherwise, it returns an error code.

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;

10楼: 多人接受答案了。