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)

System.IO.directoryInfo Accessing the subdirectories in X++

(0) ShareShare
ReportReport
Posted on by

hi there,

I have a problem where I want to process subdirectories.  I have the following code but I cannpt seem to load the subdirectory info in my loop to get the sub directory name.   I get the error "Error executing code: Wrong argument type for function."

 Can someone please let me know where I am going wrong?

Many Thanks

Paulina

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

    
    try
    {
        if (System.IO.Directory::Exists(filePath))
        {
            di = new System.IO.DirectoryInfo(filePath);
            arrayType                    = System.Type::GetType("System.IO.DirectoryInfo");
            diList                           = System.Array::CreateInstance(arrayType, 1);
            diList                           = di.GetDirectories();
            l                                   = diList.get_Length();
            info(strfmt('%1 subdirectories found in directory %2', l, filePath));
            for(i=0; i < l; i++)
            {

subDirectory = diList.getValue(i);

info(strfmt('Processing directory %1', subDirectorys.get_FullName()));

.... etc


                subdirectorys = diList.GetValue(i);

*This post is locked for comments

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

    Hi Paulina Mudgway,

    You need to use

    info(strfmt('Processing directory %1', clr2XppStr(subDirectory.get_FullName())));

    instead of

    info(strfmt('Processing directory %1', subDirectorys.get_FullName()));


  • Community Member Profile Picture
    on at

    Many thanks - worked a treat!

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