Search a folder for files?

bhalpinbhalpin Member Posts: 309
In C/AL, I need to search a folder to see if any files are present, and then process whatever files I find.

Has anyone got/seen any code to do this?

Thanks' in advance!

Bob

Comments

  • garakgarak Member Posts: 3,263
    You can use the virtual Table "FILE" like:

    Code:
    File.setrange(Path,'C:\');
    
    Path Is a file Name
    C:\   No       AltNaviDB <-- Is a folder
    C:\   No       ATI
    C:\   No       BCFONT
    C:\   No       Binaries
    C:\   No       C5450n
    C:\   No       Data
    C:\   YES      AUTOEXEC.BAT <-- is a file
    C:\   YES      AUTORUN.inf
    C:\   YES      bootfont.bin
    
    so you can loop through the folders setrange(Path,Path+NameOfFolder)
    and then you check, if there exist you needed file.

    The same principe is in this free solution

    Also, please use at first the "Search the forum" function, before you start a post ;-)

    Regards
    Do you make it right, it works too!
  • bhalpinbhalpin Member Posts: 309
    Thank's garak!

    And yes, I'll search 1st from now on.

    B
  • garakgarak Member Posts: 3,263
    ;-)

    You're welcome ...

    Please write [solved] infront of your subject title (first post). Thanks.
    Do you make it right, it works too!
  • FDickschatFDickschat Member Posts: 380
    Using the virtual table files causes one problem though:

    When you first access the table for a specific folder the NAV client somehow caches the content of the folder. At the next access to the same folder you still see the old content.

    To check this:
    - Create a form with the wizard on Table File and run it
    - Place a filter for a specific folder, note the files which are shown
    - With Windows Explorer delete a file from that folder
    - Now view your form again - It still shows the deleted file. Changing the filter (folder) does not help.

    Does anyone has any idea how to update the table file so that it shows the current content? Selectlatestversion does not help.

    Best regards, Frank
    Frank Dickschat
    FD Consulting
Sign In or Register to comment.