X++ code to move the file in batch process - Microsoft Dynamics AX2012 R3
public server static void moveFile(FileName fileName,FileName destinationPath)
{
FileName newFileName;
Filename fPath;
Filename fName;
Filename fType;
System.Exception exception;
#File
try
{
[fPath, fName, fType] = fileNameSplit(fileName);
newFileName = strFmt("%1%2%3", destinationPath, fName, fType);
if (!System.IO.File::Exists(newFileName))
{
System.IO.File::Move(fileName, newFileName);
}
else
{
System.IO.File::Delete(fileName);
}
}
catch (Exception::CLRError)
{
exception = ClrInterop::getLastException();
if (exception != null)
{
exception = exception.get_InnerException();
if (exception != null)
{
error(exception.ToString());
}
}
}
catch (Exception::Error)
{
info(strFmt("Errored",exception.ToString()));
retry;
}
}
No comments:
Post a Comment