X++ code to move the file in batch process - Microsoft Dynamics AX2012 R3

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

D365 F&O Management Reporter Troubleshoot issues opening Report Designer

  Issue 1 - Report Designer doesn't start when you select "New" or "Edit" Resolution Check the Event Viewer:   If th...