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

Announcements

No record found.

News and Announcements icon
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

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.

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    239,040 Most Valuable Professional on at

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

  • Suggested answer
    axk Profile Picture
    925 on at

    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.

  • Leo Chen Profile Picture
    Microsoft Employee on at

    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

  • doninep Profile Picture
    122 on at

    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.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 663

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 439 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 337 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans