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

How to verify that the file exists on the server?

(0) ShareShare
ReportReport
Posted on by 578

Actually i have the next code and works correctly in Client side

if(WinAPI::fileExists("c:\\Img\\11169705.png"))

{

}

but I want to apply this in Server side...

if(WinAPIServer::fileExists("c:\\Img\\11169705.png"))

{

}

and get the next error:

Error en la solicitud de permiso de tipo 'FileIOPermission'.
(S)\Classes\FileIOPermission\demand
(S)\Classes\WinAPIServer\fileExists - line 14
(C)\Jobs\_aJob90 - line 11

Can you help me?

Thank very much

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Vilmos Kintera Profile Picture
    46,149 on at

    You have access to calls in the .Net namespace, so you could use System.IO.FileInfo there which works both client- and server-side:

    [View:https://community.dynamics.com/ax/b/faisalfareedaxlibrary/archive/2016/01/10/ax-2012-file-existance-check:750:50]

    Also it was a result of a 2-mins google search, you could try it next time (ax server file exists).

    Please do not forget that if you refer a local folder path, that is pointing to the folder on your AX AOS instance instead of the local computer, so it is better to use a network file share UNC path.

    Also visit your old threads to mark the correct answers please with the checkbox next to each helpful post.

  • ismaelivan Profile Picture
    578 on at

    Hello vilmos,  

    I already tried with this code, but search in my Computer, not in the AOS Server

      System.IO.FileInfo   fileInfo;

      new InteropPermission(InteropKind::ClrInterop).assert();

      fileInfo = new System.IO.FileInfo(_fileName);

      return fileInfo.get_Exists();

  • Verified answer
    ismaelivan Profile Picture
    578 on at

    I finally shared the Folder

       FileIOPermission fioPermission;

       str data;

       new FileIOPermission("\\\\SERVER\\Img\\" ,"R").assert();

       if(WinAPI::fileExists("\\\\SERVER\\Img\\11169705.png"))

       {

           Box::info("Archivo Encontrado!");

       }

       else

       {

           Box::warning("El archivo no Existe!");

       }

  • ismaelivan Profile Picture
    578 on at

    And other code...

       System.IO.FileInfo   fileInfo;

       str file;

       new InteropPermission(InteropKind::ClrInterop).assert();

       file = "\\\\SERVER\\Img\\11169705.png";

       fileInfo = new System.IO.FileInfo(file);

       if(fileInfo.get_Exists())

       {

       }

  • Vilmos Kintera Profile Picture
    46,149 on at

    Make sure you mark my answer with the checkbox instead of yours, since the solution is indeed creating a file share, and using one of the above suggested server-side methods.

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

#1
CP04-islander Profile Picture

CP04-islander 39

#2
Michel ROY Profile Picture

Michel ROY 14

#3
imran ul haq Profile Picture

imran ul haq 8

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans