请问如何实现我指定目录下全文搜索制定字符串,有点类似查毒软件的搜索。
比如我指定 d: ,搜索“你好”,如何遍历所有文件?

解决方案 »

  1.   

    哦,对了,我还想问关于 delphi7 sample 工具栏里面有个tshelltreeview,好像很方便,如何用?help里面没有
      

  2.   

    function ClearDir(const Dir: string): Boolean;
    var
        FileInfo: TSearchRec;
        DosCode: Integer;
    begin
        Result := DirectoryExists(Dir);
        if not Result then Exit;
        DosCode := FindFirst(GetPath(Dir) + '*.*', faAnyFile, FileInfo);
        try
            while DosCode = 0 do begin
                if (FileInfo.Name[1] <> '.') and (FileInfo.Attr <> faVolumeID) then
                begin
                    if (FileInfo.Attr and faDirectory = faDirectory) then
                        Result := DelDir(GetPath(Dir) + FileInfo.Name)
                    else if (FileInfo.Attr and faVolumeID <> faVolumeID) then begin
                        if (FileInfo.Attr and SysUtils.faReadOnly = SysUtils.faReadOnly) then
                            FileSetAttr(GetPath(Dir) + FileInfo.Name, faArchive);
                        Result := DeleteFile(GetPath(Dir) + FileInfo.Name) and Result;
                    end;
                end;
                DosCode := SysUtils.FindNext(FileInfo);
            end;
        finally
            FindClose(FileInfo);
        end;
    end;
    这是一个清除目录的例子,可以参考一下
      

  3.   

    TEasyFileSearch v.1.02 (文件搜索控件)去下这个控件吧。不错
    delphi盒子里有
      

  4.   

    同意上述JavaD(一竿残照) 的看法!顶
      

  5.   

    TEasyFileSearch  www.2ccc.com