如何实现文件过滤??请教高手我现在有个题目,要求搜索一些文件,比如最简单的txt文件,通过输入一些关键字就可以知道这些文件中有哪些是包含这些内容的??(不需要打开这些文件)
另外,如果要进行扩展,比如是html,doc,zip,rar文件,甚至pdf文件,如何实现??
请给出具体方案,我是个菜鸟
我的email:[email protected]
欢迎高手程序预览图请看下列网址。
http://bbs.2ccc.com/attachments/wonder80_200453184622.jpg
另外,如果要进行扩展,比如是html,doc,zip,rar文件,甚至pdf文件,如何实现??
请给出具体方案,我是个菜鸟
我的email:[email protected]
欢迎高手程序预览图请看下列网址。
http://bbs.2ccc.com/attachments/wonder80_200453184622.jpg
解决方案 »
- fastreport 中图形报表列印问题
- ***寻求一个思路:windows任务栏的实现****
- 请教数据库查询问题,查询出来的记录如何再平均取出一半记录
- 设计的报表在别的机器上没有问题,但是在自己的机器上就是不行,郁闷大了!
- 求救!发了三回了真的没人会么?有关线程中动态调用ocx的socket的问题。
- 程序中的两个uses有什么区别的亚?
- 问题:如果要把打印做成一个公共模块(*.DLL),独立于要打印的格式和内容,要注意什么
- DateTimePicker 如何获取 小时 分钟 秒
- Windows NT下有什么类似 Win98下的ghost的工具,可以实现分区间的克隆备份?
- Delphi if in 和ord函数问题
- 如何快速操作『大文件流』
- 大家好,我刚学delphi 真羡慕那些做很棒程序的人。请教大家几个简单的问题~
procedure findall(disk,path: String; var fileresult: Tstrings);
varfpath: String;fs: TsearchRec;beginfpath:=disk+path+'\*.*'; // <----------这里变为 *.exe ,*.txt 就是过滤啦。if findfirst(fpath,faAnyFile,fs)=0 thenbeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');while findnext(fs)=0 dobeginif (fs.Name<>'.')and(fs.Name<>'..') thenif (fs.Attr and faDirectory)=faDirectory thenfindall(disk,path+'\'+fs.Name,fileresult)elsefileresult.add(disk+strpas(strupper(pchar(path)))+'\'+strpas(strupper(pchar(fs.Name)))+'('+inttostr(fs.Size)+')');end;end;findclose(fs);end;procedure DoSearchFile(Path: string; Files: TStrings = nil);varInfo: TSearchRec;procedure ProcessAFile(FileName: string);beginif Assigned(PnlPanel) thenPnlPanel.Caption := FileName;Label2.Caption := FileName;end;function IsDir: Boolean;beginwith Info doResult := (Name <> '.') and (Name <> '..') and ((attr and fadirectory) = fadirectory);end;function IsFile: Boolean;beginResult := not ((Info.Attr and faDirectory) = faDirectory);end;beginPath := IncludeTrailingBackslash(Path);tryif FindFirst(Path + '*.*', faAnyFile, Info) = 0 thenif IsFile thenProcessAFile(Path + Info.Name)else if IsDir then DoSearchFile(Path + Info.Name);while FindNext(Info) = 0 dobeginif IsDir thenDoSearchFile(Path + Info.Name)else if IsFile thenProcessAFile(Path + Info.Name);Application.ProcessMessages;if QuitFlag then Break;Sleep(100);end;finallyFindClose(Info);end;end;
一般都是打开文件,全文搜索,只是不把文件显示出来给你看罢了。