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 :
Dynamics 365 Community / Forums / Finance forum / WinAPI is deprecated -...
Finance forum

WinAPI is deprecated - how to replace this class?

(0) ShareShare
ReportReport
Posted on by 70

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.

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Dynamics 365 for Operations is a cloud service and can't see any local folders on your computer or your company's network. The only way it can access files on your computer is that  you send the files to it by manually by web browser (similar than any uploads to web based solutions such as Gmail, Facebook etc).

    If you really need to read automatically from local folders, you have to use a middle man - an integration platform that will read from the folders and send data to D365FO web service. There are plenty of such solutions out there, such as Logic Apps (a cloud service but you can add an on premises data gateway to it), Biztalk etc.

    Also, here is a free sample app that you can use to try such integration scenarios: github.com/.../Recurring-Integrations-Scheduler

    It's a new world and you need to think a bit differently. The technical solution to a business requirement is not necessarily the same than it was with AX4.0.

    Can you share your business requirement?

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    To elaborate on Nikolaos' answer, there is a pattern and form control to deal with "uploading" files to D365FO.

    docs.microsoft.com/.../file-upload-control

    If you search the AOT you should also find examples of standard code that use this control and pattern.

  • Bilal Jawarneh Profile Picture
    56 on at

    An the same concepts are applied for On premise?

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans