现在在图片这个文件夹下面有两个图片,分别是 :20070601001.bmp和20070601002.bmp这两个图片文件,如果我用程序来实现来搜索这个文件夹,得到这个20070601002.bmp中的20070601002的文件名呢 ?请各位大侠赐教,谢谢!~

解决方案 »

  1.   

    procedure TformMain.GetTransfersFile(Pathname: string);
    var
      FindData: TWin32FindData;
      hf:THandle;
      b:boolean;
      tmpstr:string;
      tempFolder:string;
      str:string;
      BTime,ETime:TDateTime;
      p_FileInfo:PFileInfo;
      FileType:string;
    begin
      hf := Windows.FindFirstFile(PChar(pathname + '\*.*'), FindData);
      if hf = INVALID_HANDLE_VALUE then Exit;
      b := true;
      while b do
      begin
        if ( FindData.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY ) = 0 then
        begin
          str:=string( FindData.cFileName );
          listbox1.items.add( str );//处理文件名 copy/leftstr/rightstr
        end
        else
        begin
          tmpstr := FindData.cFileName + '';
          if (tmpstr <> '.') and (tmpstr <> '..') then
          begin
            tempFolder:=tempFolder+string(FindData.cFileName)+'\';
            GetTransfersFile(pathname + '\' + FindData.cFileName,DestFPath,aMsgInfo);
          end;
        end;
        b := windows.FindNextFile(hf,FindData);
      end;
    end;
      

  2.   

    我的意思就是:其实,我想把图片存到这个文件夹下面的 。现在里面有两张图片来了,分别是:20070601001.bmp和20070601002.bmp,如果加入第三张的话,那新增的那个文件名就应该是:20070601003.bmp了。请问这个如何实现呢?
      

  3.   

    用一个控件 FileListBox  在Win3.1下
    FileListBox1.Mask:='*.bmp'; //文件类型
    FileListBox1.ApplyFilePath(文件夹路径);//
    //下面是文件获取名字
    for forI := 0 to FileListBox1.Count - 1 do
    begin
     name:=FileListBox1.Items.Strings[forI];
     fname := copy(name,1,length(name)-4);
    end;
    ----------------------------
    上面的应该可以解决你的问题了
      

  4.   

    var
      sr : TSearchRec;
      FileAttrs: Integer;
    begin
      FileAttrs := faAnyFile;  if FindFirst('E:\*.bmp',FileAttrs,sr)=0 then
      begin
        repeat
          if (sr.Attr and FileAttrs) = sr.Attr then
          begin
            Memo1.Lines.Add(Copy(sr.Name,1,
              LastDelimiter('.' + PathDelim + DriveDelim, sr.Name)-1));
          end;
        until FindNext(sr) <> 0;
        FindClose(sr);
     end;
    end;