Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Files Move from one folder to another in AX2102

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

After running my batch job on server ,files has to be moved from one folder to another folder in ax2012.Do we have a sample code for this requirement.

  • doninep Profile Picture
    doninep 120 on at
    RE: Files Move from one folder to another in AX2102

    I have used System.IO as Martin recommends.  Make sure that the AOS Service account has permissions to the from and to locations for you file(s).  When running in batch mode the code will use the AOS Service account for file system access.

  • Leo Chen Profile Picture
    Leo Chen on at
    RE: Files Move from one folder to another in AX2102

    If it turns out that the batch needs to run on a client session, you can refer to below article to enable it

    docs.microsoft.com/.../walkthrough-extending-runbasebatch-class-to-create-and-run-a-batch

  • Suggested answer
    axk Profile Picture
    axk 925 on at
    RE: Files Move from one folder to another in AX2102

    Please check the WinAPI and WinAPIServer classes. There are methods to work with files like fileExists, copyFile, deleteFile. You can check DocuRef.delete() method to see how the system handles the file deletion on the client and how it is handled on the server.

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 231,321 Most Valuable Professional on at
    RE: Files Move from one folder to another in AX2102

    I would use System.IO.File::Move(). For example:

    InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);
    permission.assert();
    
    try
    {
    	System.IO.File::Move(@'\\locationSharedByAllAos\from\file.txt', @'\\locationSharedByAllAos\to\file.txt');
    }
    catch (Exception::CLRError)
    {
    	throw error(AifUtil::getClrErrorMessage());
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,321 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans