搜档网
当前位置:搜档网 › idFTP判断文件夹是否存在

idFTP判断文件夹是否存在

idFTP判断文件夹是否存在
2009-09-11 12:03
TIdFtp 元件沒有 DirectoryExists 及 FileExists 函式
1.判斷 Directory(要先連上 Ftp Server)

function FtpDirectoryExists(ADir: string): Boolean;
begin
Result := True;
try
IdFtp1.ChangeDir(ADir);
except
Result := False;
end;
end;


2.判斷 File

function FtpFileExists(AFile: string): Boolean;
var
sl: TStringList;
begin
Result := False;
sl := TStringList.Create;
try
IdFtp1.Connect;
IdFtp1.ChangeDir('some_dir');
IdFtp1.List(sl.Strings, '', False);
if Pos(AFile, sl.Text) <> 0 then
Result := True;
IdFtp1.Disconnect;
finally
sl.Free;
end;
end;

相关主题