如何实现文件过滤??请教高手我现在有个题目,要求搜索一些文件,比如最简单的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
解决方案 »
- delphi 急!!!关于粘贴板的用法的。
- 求EXE压缩原理。求EXE压缩原理。求EXE压缩原理。
- 我做的一个dll,为什么在DELPHI6下可以编译,而delphi5不行?
- 求助!关于Delphi6的打包问题
- 在线程中如何,快速传递数据?????
- 为什么用在进行连续打印时,只能打印出第一页,第二页后是黑块?
- 偶有重回delphi修炼了,当年偶的师傅还在吗?老千,老鱼,chech,小新,老鬼,你们过的怎样??
- 哪位知道在一个控件中怎样截获主程序收到的所有消息 ?
- 如何判断Tedit中输入的日期是合法的?
- 如何提高我这个程序的执行效率?
- 如何快速操作『大文件流』
- 大家好,我刚学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;
一般都是打开文件,全文搜索,只是不把文件显示出来给你看罢了。