Tuesday, February 12, 2013

Loop over XPO files in a file location using X++ in AX

The following is code that will loop over all files in a location that are .xpo files. You can change the 'xpo' below to 'txt' or whatever,. It should work for all of it.

static void daxLoopOverFilesInFolder(Args _args)
    FilePath    filePath = 'C:\\Users\\daxdude\\Desktop\\XPO location\\';
    filePath    fileFilter = '\\*.xpo'; // Only want to look at XPO files
    FileName    fileName;    
    int         fileHandle;

    [fileHandle, fileName] = WinAPI::findFirstFile(filePath + fileFilter);
        info(strFmt("%1%2", filePath, fileName));
        // Get next file
        fileName = winAPI::findNextFile(fileHandle);

No comments:

Post a Comment