Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Files can't be found using wildcard.

(0) ShareShare
ReportReport
Posted on by

In a customers environment NAV2015 CU4 when searching for the file-contents of a directory, nothing is found.

Using GET or filter on a existing complete filename files can be found. How come wildcards in filter can't return a list of files??  Needs Clues in order to fix this so please any and all ideas are welcome.

Example code:


Local VAR:
Name DataType Subtype Length
MicrobizzSetup Record Microbizz Setup 
FileRec Record File 


MicrobizzSetup.GET;

CLEAR(FileRec);
FileRec.RESET;
FileRec.INIT;
FileRec.SETRANGE(Path,MicrobizzSetup."Inbound Processed File Path");
IF FileRec.FINDFIRST THEN;

FileRec.SETRANGE(Path,MicrobizzSetup."Inbound File Path");
IF FileRec.FINDFIRST THEN
  MESSAGE('1. - OK\'+FileRec.Path +'\'+FileRec.Name)
ELSE
  MESSAGE('ERROR - FILE NOT FOUND #1\'+FileRec.GETFILTERS);  //THIS IS RETURNED

CLEAR(FileRec);
FileRec.RESET;
FileRec.INIT;
FileRec.SETRANGE(Path,MicrobizzSetup."Inbound Processed File Path");
IF FileRec.FINDFIRST THEN;

FileRec.SETRANGE(Path,MicrobizzSetup."Inbound File Path");
FileRec.SETRANGE("Is a file",TRUE);

IF FileRec.FINDFIRST THEN
  MESSAGE('2. - OK\'+FileRec.Path +'\'+FileRec.Name)
ELSE
  MESSAGE('ERROR - FILE NOT FOUND #2\'+FileRec.GETFILTERS);  //THIS IS RETURNED


CLEAR(FileRec);
FileRec.RESET;
FileRec.INIT;
FileRec.SETRANGE(Path,MicrobizzSetup."Inbound Processed File Path");
IF FileRec.FINDFIRST THEN;

FileRec.SETRANGE(Path,MicrobizzSetup."Inbound File Path");
FileRec.SETRANGE("Is a file",TRUE);
FileRec.SETFILTER(Name,'*.xml');
IF FileRec.FINDFIRST THEN
  MESSAGE('3. - OK\'+FileRec.Path +'\'+FileRec.Name)
ELSE
  MESSAGE('ERROR - FILE NOT FOUND #3\'+FileRec.GETFILTERS);  //THIS IS RETURNED


CLEAR(FileRec);
FileRec.RESET;
FileRec.INIT;
FileRec.SETRANGE(Path,MicrobizzSetup."Inbound Processed File Path");
IF FileRec.FINDFIRST THEN;

FileRec.SETRANGE(Path,MicrobizzSetup."Inbound File Path");
FileRec.SETRANGE("Is a file",TRUE);
FileRec.SETFILTER(Name,'2016-02-02T15-51-03_requisitions.xml');
IF FileRec.FINDFIRST THEN
  MESSAGE('4. - OK\'+FileRec.Path +'\'+FileRec.Name)   //THIS IS RETURNED
ELSE
  MESSAGE('ERROR - FILE NOT FOUND #4\'+FileRec.GETFILTERS);


CLEAR(FileRec);
FileRec.RESET;
FileRec.INIT;

IF FileRec.GET(MicrobizzSetup."Inbound File Path",TRUE,'2016-02-05T08-40-03_requisitions.xml') THEN
  MESSAGE('5. - OK\'+FileRec.Path +'\'+FileRec.Name)   //THIS IS RETURNED
ELSE
  MESSAGE('ERROR - FILE NOT FOUND #5\'+FileRec.GETFILTERS);

   

*This post is locked for comments

  • Community Member Profile Picture
    on at
    RE: Files can't be found using wildcard.

    That is really strange. I am able to get the list of files in my local DB using the file table (both in NAV 2015 & NAV 2016 version).

    Anyway, it's good that you found the solution using dot net automation.

    Regards,

    Vishal Salot

    //If this answer helps you, please mark it as verified.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Files can't be found using wildcard.

    Hmm Still no listing...  The setup points to a valid path. The Path holds files which can be shown using Explorer. The files just will not find their way into the system table FILE

    Have just now tested a DotNet solution that works:

    - VAR SETUP -

    Name DataType Subtype Length

    DNObject DotNet System.Object.'mscorlib

    DNFolder DotNet System.IO.Directory.'mscorlib

    DNList DotNet System.Collections.Generic.List`1.'mscorlib,

    DNFile DotNet System.IO.File.'mscorlib,

    DNPath DotNet System.IO.Path.'mscorlib,

    - CODE -

    DNObject := DNFolder.GetFiles(MicrobizzSetup."Inbound File Path",'*.xml');

    DNList := DNList.List;

    DNList.AddRange(DNObject);

    FOR i := 0 TO DNList.Count - 1 DO BEGIN

     MESSAGE(DNPath.GetFileName(DNList.Item(i)));

    END;

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Files can't be found using wildcard.

    Hi,

    Just try as follow and let me know the results.

    MicrobizzSetup.Get;

    IF MicrobizzSetup."Inbound File Path" <> '' THEN BEGIN

     CLEAR(FileRec);

     FileRec.SETRANGE(Path,MicrobizzSetup."Inbound File Path");

     FileRec.SETRANGE("Is a file",TRUE);

     IF FileRec.FINDFIRST THEN

     Repeat

       MESSAGE('1. - OK\'+FileRec.Path +'\'+FileRec.Name)

     Until  FileRec.Next = 0;

    End

    Else

     Error('Path Not Found');

    Regards,

    Vishal Salot

    //If this answer helps you, please mark it as verified.

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Leaderboard > Microsoft Dynamics NAV (Archived)

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2

#1
mmv Profile Picture

mmv 2

#1
Amol Salvi Profile Picture

Amol Salvi 2

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans