我用ShellListView打开U盘,但是我不知道U盘里面哪个文件夹下有视频文件。
可以用什么方法搜索?根目录的搜索我会,就是不知道怎么搜索子文件夹的。我想知道哪个文件夹里面有视频,得到它的路径,然后再用ShellListView直接打开有视频的文件夹。高手给我说说啊!我才学delphi的!

解决方案 »

  1.   

    递归搜索。给个我写的现成函数:Procedure GetFileListLoop(FPath : String;Mask : String;FList : TStrings);
    Var
      sMask: string;
      TMask: String;
      P : Integer;
      FResult : Integer;
      SearchRec : TSearchrec;
    begin
      If FPath = '' then Exit;  if FList = nil then Exit;  If FPath[Length(FPath)]<>'\' then
        Fpath := FPath + '\';
      If NOT DirectoryExists(FPath) then Exit;  sMask := Mask;
      While sMask <> '' do
      begin
        P := Pos(';',sMask);
        If P = 0 then
          P := Succ(Length(sMask));
        TMask := Copy(sMask,1,Pred(P));
        Delete(sMask,1,P);
        
        FResult := SysUtils.FindFirst(FPath + TMask,faAnyFile,SearchRec);
        while FResult = 0 do
        begin
          if (SearchRec.Name <> '.') and (SearchRec.Name <> '..') then
            if SearchRec.Attr = faDirectory then
              GetFileListLoop(FPath + SearchRec.Name,Mask,FList)
            else
              FList.Add(FPath + SearchRec.Name);
          FResult := SysUtils.FindNext(SearchRec);
        end;
        SysUtils.FindClose(SearchRec);
      end;
    end;调用: GetFileListLoop('c:\','*.avi;*.mpg',files);
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
    files:TStrings;
    begin
      GetFileListLoop('c:\','*.txt;*.bmp',files);
      showmessage(files.Text);
    end;
    调用不对,正确方法应该怎么显示?
      

  3.   

    lz的图片充分显示了lz是从北大青鸟出来的