AX connect to ftp server

48 Views Asked by At

I have an FTP server and a login and password I have to create a button that tests the connection for access to an FTP server with a login and password, how can I do it

best regards.

1

There are 1 best solutions below

0
10p On
str ftpAddress  = 'ftp://ftp.company.com';
str username    = 'user';
str password    = 'password';
System.Object ftpo = System.Net.WebRequest::Create(ftpAddress);
System.Net.FtpWebRequest request = ftpo;

request.set_Credentials(new System.Net.NetworkCredential(username, password));
request.set_Method("PWD");

try
{
    request.GetResponse();
    info('All OK');
}
catch(Exception::CLRError)
{
    error(AifUtil::getClrErrorMessage());
}