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 :
Microsoft Dynamics AX (Archived)

MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

(0) ShareShare
ReportReport
Posted on by 570

Hi All,

I follow below code for file move from one folder to other folder using below Code.

     Set                 permissionSet;
    permissionSet =  new Set(Types::Class);
    permissionSet.add(new FileIOPermission(fileName, #io_write));
    permissionSet.add(new FileIOPermission(newFileName, #io_write));
    permissionSet.add(new InteropPermission(InteropKind::ClrInterop));
    CodeAccessPermission::assertMultiple(permissionSet);
    System.IO.File::Move(fileName, newFileName);
    CodeAccessPermission::revertAssert();

while  am using am facing below error 

213231.Capture.PNG

I try  to  solve above error using the  below dll 

4101.dll.PNG

After adding Dll also am facing error, can anyone please explain me to solve this error.

Thanks

Tony

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Tony,

    It cannot find a file. Where do you run this code? If you run it on server then file should be accessible from the server and AOS user should have access to it.

  • TonyAx Profile Picture
    570 on at

    Thanks for quick reply am running the code on the server.

  • Mea_ Profile Picture
    60,284 on at

    So, coming back to my questions:

    Is your file in shared folder, so server could have access to it over network or in local folder on the same server? Does AOS user have access to it ?

  • TonyAx Profile Picture
    570 on at

    File on the local folder I give full permission to that folder also, but code not working

  • Mea_ Profile Picture
    60,284 on at

    So, are you running client from the AOS server ? Your file sits in downloads folder, so you should either be connected straight to the the server or you need to put your file into a shared folder if you execute the code on the server tier.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans