Hi Martin I am having some progress, but I still have a issue using C# library.
I have created C# Library and also tested the code from a different C# project so I know the code is working.(Returning the correct results) I have added the library as reference to my X++ Project and also added it with Using in my class(Not sure if this is necessary) However when I try to call my method it does not find it and gives an error "Method 'getFileList() is not found on type "PBFCListDirectory.FtpList). What can I have missed here?. When I type, intellisense picks up the Namespace and the class but then does not pick up the method.
Am I calling the method correctly from X++?
//using PBFCListDirectory;
class PBFJobTestFtp
{
/// <summary>
/// Runs the class with the specified arguments.
/// </summary>
/// <param name = "_args">The specified arguments.</param>
public static void main(Args _args)
{
DMFParameters dmfParameter;
List fileList = new List(Types::String);
ListIterator iterator;
str dwnldFile;
boolean success;
PBFCListDirectory.FtpList ftpList = new PBFCListDirectory.FtpList();
dmfParameter = DMFParameters::find();
fileList = ftpList.getFileList('server','folder','User','Password'); //error on this line
iterator = new ListIterator(fileList);
while(iterator.more())
{
dwnldFile = iterator.value();
success = PBFAzureStorageControl::downloadFile(dwnldFile);
ftpList.movefile('server','folder','User','Password',dwnldFile, success); //error on this line
iterator.next();
}
}
}
Below is the moveFile method. I tried it with the static and without
public static void moveFile(String Server, String from_Netstock, String UserId, String Password, string nameImport, bool success)
{
string filePathTo = null;
FtpWebRequest ftpRequest = null;
FtpWebResponse ftpResponse = null;
if (success == true)
{
filePathTo = "success/" + nameImport;
}
else
{
filePathTo = "failure/" + nameImport;
}
try
{
ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://" + Server + "/" + from_Netstock + "/" + nameImport);
ftpRequest.Credentials = new NetworkCredential(UserId, Password);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = true;
ftpRequest.Method = WebRequestMethods.Ftp.Rename;
ftpRequest.RenameTo = filePathTo;
ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
ftpResponse.Close();
ftpRequest = null;
}
catch (WebException e )
{
string status = ((FtpWebResponse)e.Response).StatusDescription;
}
}