问题同标题!
如果不复杂的话请给出代码让我参考!!!!
谢谢咯!

解决方案 »

  1.   

    返回指定目录下所有文件名的列表,fileAttr是文件的属性,返回的结果只包括文件名,
    不包括路径和扩展名。
      参数Path既包括所搜索的文件所在的目录,也包括文件名称,如:
      如果出现错误,则抛出EWin32Error异常,测试程序见lib\GetFileNameListfunction GetFileNameList(const Path: String; fileAttr: integer): TStrings;  procedure RaiseError(Win32ErrNo: DWORD);
      var
        E: EWin32Error;
      begin
        if (Win32ErrNo <> ERROR_NO_MORE_FILES) and
          (Win32ErrNo <> ERROR_FILE_NOT_FOUND) and
          (Win32ErrNo <> ERROR_PATH_NOT_FOUND) then
        begin
          E := EWin32Error.CreateFmt(SWin32Error, [Win32ErrNo,SysErrorMessage(Win32ErrNo)]);
          E.ErrorCode := Win32ErrNo;
          raise E;
        end;
      end;  function ExtractRealFileName(Const FileName: String): String;
      var
        I: integer;
      begin
        I := LastDelimiter('.',FileName);
        if i = 0 then
          i := MAXInt
        else
          Dec(i);
        result := Copy(FileName, 1, i);
      end;var
      f: TSearchRec;
      LastError: DWORD;
    begin
      result := TStringList.Create;
      try
        LastError := FindFirst(Path,fileAttr,f);
        if LastError <> 0 then
        begin
          RaiseError(LastError);
          exit;
        end;
        result.Add(ExtractRealFileName(f.Name));
        try
          LastError := FindNext(f);
          while LastError = 0 do
          begin
            result.Add(ExtractRealFileName(f.Name));
            LastError := FindNext(f);
          end;
          RaiseError(LastError);
        finally
          SysUtils.FindClose(f);
        end;
      except
        result.Free;
        raise;
      end;
    end;
      

  2.   

    获得文件夹:
    function ListDirs(Path: string; List: TStringList): Integer;
    var
      FindData: TWin32FindData;
      FindHandle: THandle;
      FileName: string;
      AddToList: Boolean;
    begin
      Result := 0;
      AddToList := Assigned(List);  if Path[Length(Path)] <> '\' then
        Path := Path + '\';  Path := Path + '*.*';  FindHandle := Windows.FindFirstFile(PChar(Path), FindData);
      while FindHandle <> INVALID_HANDLE_VALUE do
      begin
        FileName := StrPas(FindData.cFileName);
        if (FileName <> '.') and (FileName <> '..') and
          ((FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY) <> 0) then
        begin
          Inc(Result);
          if AddToList then
            List.Add(FileName);
        end;    if not Windows.FindNextFile(FindHandle, FindData) then
          FindHandle := INVALID_HANDLE_VALUE;
      end;
      Windows.FindClose(FindHandle);
    end;使用:
    var
      s: TStringList;
    begin
      s := TStringList.Create;
      ListDirs('c:\windows\', s);
      ListBox1.Items.AddStrings(s);
      s.Free;
    end;
      

  3.   

    放一个FileListBox就可以了啊。
      

  4.   

    在FORM1上加一个EDIT和MEMO,
    导入一个目录,
    然后在MEMO1中就会显示出所有的文件夹和名称
    procedure TForm1.seachfile(path : string);
    var
      sr: TSearchRec;
    begin
    if FindFirst(path+'\*.*',faanyfile, sr) = 0 then
    repeat
    if (sr.name<>'.') and (sr.name<>'..') then
    //如果是目录
    if (sr.Attr and fadirectory) = fadirectory then
      SeachFile(path+'\'+sr.name)
    else
    begin
    //如果是后缀名相同于EDIT1的文件名
    if lowercase(strright(sr.name,4))=lowercase(strright(edit2.text,4)) then
     memo1.lines.add(path+'\'+sr.name);
     end;
    until findnext(sr)<>0;
     findclose(sr);
    end;
      

  5.   

    最简单的方法:放一个FileListBox,它的默认Path就是当前目录,然后把它当ListBox 那样用用就可以了啊呀耶~~~~~~
      

  6.   

    难道我添加了FILELISTBOX后,又把它隐藏吗???
    我就是不想这样做,麻烦你们费心了!!
      

  7.   

    呵呵
    理解能力有限啊
    这样就简单多了,只用这样就可以列出在一个目录下的文件名,
    列出子文件夹与此类同
    procedure TForm1.Button13Click(Sender: TObject);
    var s : string;
        i : integer;
        sr: TSearchRec;
    begin
     listbox1.Items.Clear;
     if FindFirst(d1.directory+'\*.*', faAnyFile, sr) = 0 then
     begin
     ListBox1.Items.Add(d1.directory+'\'+sr.Name);
     while FindNext(sr) = 0 do
     ListBox1.Items.Add(d1.directory+'\'+sr.name);
     FindClose(SR);
    end;
    end;
      

  8.   

    呵呵我的上一部分代码把子目录一起列出来了,
    可以加一个判断if (sr.Attr and fadirectory) = fadirectory then满足条件的,就是子目录
      

  9.   

    http://vip.6to23.com/aizb/docu/filelist.zip
    自己看,很好的例子
      

  10.   

    以下代码是列出一个目录下的所有文件(不包含文件夹), 你只要在FORM1加一个LISTBOX和一个BUTTON,就可以看效果当然你也能改造把它变成一个函数procedure TForm1.Button13Click(Sender: TObject);
    var s : string;
        i : integer;
        sr: TSearchRec;
    begin
     listbox1.Items.Clear;
     if FindFirst('c:\windows'+'\*.*', faAnyFile, sr) = 0 then
     begin
     begin
     if not((sr.Attr and fadirectory) = fadirectory) then
     ListBox1.Items.Add(d1.directory+'\'+sr.Name);
     while FindNext(sr) = 0 do
     begin
     if not((sr.Attr and fadirectory) = fadirectory) then
     ListBox1.Items.Add(d1.directory+'\'+sr.name);
     end;
     FindClose(SR);
    end;
    end;
    end;