procedure MakeTree(FilePath:String; AllowType:String; FindSubDir:Boolean); var Sr:TsearchRec; Err:Integer; FilesName:String; TpOriPic,tpDescPic:TMemoryStream; begin Err:=FindFirst('*.*',$37,sr); while (Err=0) do begin if Sr.Name[1]<>'.' then begin case (Sr.Attr and faDirectory) of 0: //添加可用图片 begin FilesName:=trim(UpperCase(sr.Name));// showMessage(ExtractFilePath(FilesName)+ExtractFileExt(FilesName)); if Pos(ExtractFileExt(FilesName),UpperCase(AllowType))>0 then with ClientDataSetSmp_Sample do begin try AnytoJpg(FilesName, tpOriPic, utMaxSize, utMaxWH); tpDescPic:=TMemoryStream.Create; if Assigned(tpOriPic) then begin Append; tpOriPic.Position:=0; ZoomPic(tpOriPic,utPicWidth,utPicHeight,tpDescPic); //将图片缩小成指定大小 tpDescPic.Seek(0,0); FieldByName('ItemNo').AsString:=Copy(FilesName,1,Length(FilesName)-4); FieldByName('GoodsCode').AsString:=self.deDefGoodsCode.Text; with dcSortCode do if (KeyItems.Count > 0) and (ItemIndex >=0) then FieldByName('SortCode').AsString:= KeyItems.Strings[ItemIndex]; if Not StrIsEmpty(deBelong.Text) then FieldByName('Belong').AsString := Trim(deBelong.Text); TBlobField(FieldByName('Picture')).LoadFromStream(tpOriPic); TBlobField(FieldByName('SmallPic')).LoadFromStream(tpDescPic); Post; end; Finally tpOriPic.Free; tpDescPic.Free; end; end; end; 16://目录 begin if FindSubDir then begin //是否查找子目录 ChDir(Sr.Name); MakeTree(Sr.Name, AllowType, FindSubDir); ChDir('..'); end; end; end; end; Err:=FindNext(Sr); end; end;给你一段代码参考