The WinApi class holds some nice functions for file manipulation, like the WinApi::fileExistsWinApi::copyFileWinApi::deleteFileWinApi::moveFile I think every programmer has used one of those functions in Ax at one time or another, as they can be really helpful. They have one big drawback though: They need to be executed on the client tier. Trying to use…
Tag: WinAPI
Microsoft Dynamics Ax
Stack trace: Invalid attempt to call WinAPI::findFirstFile running in CIL on the client.
by Bo Jensen •
This error you will normally encounter when running a batch job. The issue is that batch processing doesn’t suppport WINAPI::findFirstFile method. Actually I was trying to find a file in the folder and moving to some other folder, you can use this alternative: public void run(){ System.IO.DirectoryInfo di; System.Type arrayType; System.Array array; System.IO.FileInfo fi; FilePath…
Microsoft Dynamics Ax
Dynamics AX: Read All Files inside a directory
by Bo Jensen •
void FindAllCSV() { #Evat_NL #File Filename baseFolder; Filename csvFilename; Filename foundBaseFileName; Filename foundFileName; container mainFolder, subFolder, fileContainer; boolean filesFoundMainFolder = true; boolean filesFoundSubFolder = true; int apiResult; int setCurrentFolder (Filename _filename = ”) { ; return WinAPI::setCurrentDirectory(_filename); } ; baseFolder = “C:TEST”; apiResult = setCurrentFolder(SysTreeNode::duplicatePathDelimiters(baseFolder)); mainFolder = WinAPI::findFirstFile(“*.*”); foundBaseFileName = conpeek(mainFolder, 2); while (filesFoundMainFolder) {…
Microsoft Dynamics Ax
How to import multiple file from a folder? – Microsoft Dynamics AX
by Bo Jensen •
container createListOfFiles(FilePath _path = path, FileNameType _pattern = pattern) { System.Array files; int fileCount; int i; str nextFile; new InteropPermission(InteropKind::ClrInterop).assert(); info(strfmt(‘Search in: %1 %2’, _path, _pattern)); listOfFiles = connull(); actIx = 0; files = System.IO.Directory::GetFiles(_path, _pattern); if (files) { fileCount = files.get_Length(); info(strFmt(‘Number of…