Hi All,
I nee to copy all file in folder INP to folder Archive in ftp by X++. I only found out when using the 'RENAME' method but only moved the file. How can I move the file from INP to Archive but the file in INP still exists?
This is my code
private str rename(filename fileNameString)
{
System.Net.FtpWebRequest request;
System.Net.NetworkCredential credential;
System.Net.FtpWebResponse response;
Filename filepath, filename;
Filename fileType, resultfile;
System.IO.StreamReader reader;
System.Byte[] bytes;
System.Text.Encoding utf8;
try
{
KREFTPParameter FTPParameter = KREFTPParameter::find();
KREDataEntityExportLogHeader entDest = KREDataEntityExportLogHeader::find();
str OriftpUrlarc = FTPParameter.servername + entDest.FTPINP + fileNameString;
credential = new System.Net.NetworkCredential("","","");
credential.username = FTPParameter.UserName;
credential.password = FTPParameter.passwordEdit(false,"");
request = System.Net.WebRequest::Create(OriftpUrlarc);
request.set_Credentials(credential);
request.set_Method("RENAME");
request.set_RenameTo(entDest.FTPArchive + fileNameString);
response = request.GetResponse();
resultfile = FTPParameter.servername + entDest.FTPArchive + fileNameString;
}
catch(Exception::CLRError)
{
throw error(AifUtil::getClrErrorMessage());
}
return resultfile;
}
Thanks,