******怎样用IdFTP上传文件夹? ( 积分: 300 )

  • 主题发起人 主题发起人 lctuchen
  • 开始时间 开始时间
L

lctuchen

Unregistered / Unconfirmed
GUEST, unregistred user!
我上传文件没问题,怎么上传文件夹总出错,说找不到文件路径。
哪位帮帮忙,多谢!!

procedure tfrmmain.UploadDir(idFTP : TIdFtp; LocalDir:string; RemoteDir: string);
var
s:tsearchrec;
i:integer;
begin
//判断服务器是否存在相应Local目录,如没有,新建之
//i:=findfirst(LocalDir,fadirectory,s);

IdFTP.TransferType := ftBinary;
//strPath:=LocalDir+'/'+extractfilename(s.Name);
IdFTP.Put(LocalDir+'/' ,'',false);
//IdFTp.ChangeDir(RemoteDir);

i:=findfirst(LocalDir+'/*.*',faAnyFile,s);
while i=0 do
begin
if s.name[1]<>'.' then
begin
if (s.attr and fadirectory)=fadirectory then
begin
uploaddir(idftp, LocalDir+'/'+s.name,idftp.RetrieveCurrentDir +'/'+s.name);
end
else
//是文件,直接上传
//IdFTP.Put(LocalDir+'/'+s.name);
Idftp.Put(LocalDir+'/'+s.name,idftp.RetrieveCurrentDir +'/'+s.name,false);
end;
i:=findnext(s);
end;
end;
 
我上传文件没问题,怎么上传文件夹总出错,说找不到文件路径。
哪位帮帮忙,多谢!!

procedure tfrmmain.UploadDir(idFTP : TIdFtp; LocalDir:string; RemoteDir: string);
var
s:tsearchrec;
i:integer;
begin
//判断服务器是否存在相应Local目录,如没有,新建之
//i:=findfirst(LocalDir,fadirectory,s);

IdFTP.TransferType := ftBinary;
//strPath:=LocalDir+'/'+extractfilename(s.Name);
IdFTP.Put(LocalDir+'/' ,'',false);
//IdFTp.ChangeDir(RemoteDir);

i:=findfirst(LocalDir+'/*.*',faAnyFile,s);
while i=0 do
begin
if s.name[1]<>'.' then
begin
if (s.attr and fadirectory)=fadirectory then
begin
uploaddir(idftp, LocalDir+'/'+s.name,idftp.RetrieveCurrentDir +'/'+s.name);
end
else
//是文件,直接上传
//IdFTP.Put(LocalDir+'/'+s.name);
Idftp.Put(LocalDir+'/'+s.name,idftp.RetrieveCurrentDir +'/'+s.name,false);
end;
i:=findnext(s);
end;
end;
 
后退
顶部