这个很简单,提供给你一个判断ftp文件夹是否存在的函数,可以借鉴
function FTPHasDirectary(ftp : TIdFTP;SFatherDirect,SDirectName : string) : boolean;
var
LS : TStringList;
i : integer;
begin
result := false;
if (not assigned(ftp)) or (not ftp.Connected) then exit;
try
try
LS := TStringList.Create;
ftp.TransferType := ftASCII; //重要
ftp.ChangeDir(SFatherDirect);
ftp.List(LS);//使用TStringList保存列表
if LS.Count = 0 then exit;
for i := 0 to LS.Count - 1 do
begin
if AnsiPos(SDirectName,LS.Strings[i]) > 0 then
begin
result := true;
exit;
end;
end;
except
end;
finally
FreeAndNil(LS);
end;
end;