Hello everyone,
I have a problem with WinAPi->FindFirstFile, FindNextFile etc. This class is deprecated, how to replace this? I want to download some files csv from folder, in AX 4.0 this method looks like this:
void clicked() { FilePath filePath = "\\\\192.192.192.192\\Catalog\\FolderName\\"+date2str(systemdateget(),321,2,3,2,3,4)+"\\"; FileNameFilter fileFilter = ["*.*", "All files"]; FileName fileName2; int fileHandle; MyClass myClass = new MyClass(); int i =0; int counterRetry; [fileHandle, fileName2] = WinAPI::findFirstFile(strFmt("%1\\%2",filePath, conPeek(fileFilter, 1))); //info(date2str(systemdateget(),321,2,3,2,3,4)); // While files found while(fileName2) { // info(strfmt('%1',fileName2)); fileName2 = winAPI::findNextFile(fileHandle); if (filename2 != '.' && filename2 != '..' && filename2 != '') { try { //info(filePath+''+filename2); MyClass.CreateSomethingFromReadFile(filePath+''+strrtrim(strltrim(filename2))); i++; } catch(Exception::Deadlock) { if (counterRetry < 100) retry; ++counterRetry; } catch(Exception::Error) { throw Error("Import Canceled!"); } } } super(); info(strfmt('Import end, download %1 files',i)); FormDataSource_ds.executeQuery(); }
Could you help ?
I must read all files from folder.