microsoft-dynamicsdynamics-navdynamics-nav-2013dynamics-nav-2015

List of files from a directory ordered by date


How can I get a list of files from directory ordered by date in NAV? I can't use the File virtual table because there is no key for the date. I've tried with DotNet but implementing the IComparer interface is far too complicated for me.

Any ideas?

Cheers


Solution

  • As a low-tech solution (i.e. not requiring any external components), how about creating a temporary File record variable in which you buffer the file records, populating the Path field with a sortable string representation of the file's Date and Time fields combined into a DateTime? [Please ignore that PAGE.RUN - that was there just for debugging purposes.]

    Code

    On my machine, the first call to ShowFileOrder displays this:

    Sorted by name

    The second call shows this:

    enter image description here

    And this is what the files look like in Windows Explorer:

    enter image description here

    I hope this helps! :)