Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

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

Posted on by 562

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

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

    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.

  • TonyAx Profile Picture
    TonyAx 562 on at
    RE: MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

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

  • Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

    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
    TonyAx 562 on at
    RE: MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

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

  • Suggested answer
    Mea_ Profile Picture
    Mea_ 60,278 on at
    RE: MOVE FILE FROM ONE FOLDER TO ANOTHER FOLDER USING X++

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans