web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

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

Community Member Profile Picture Community Member

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;
    }

}


This was originally posted here.

Comments

*This post is locked for comments