Skip to main content

Notifications

Microsoft Dynamics NAV (Archived)

Files can't be found using wildcard.

Posted on by Microsoft Employee

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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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
    Community Member Microsoft Employee 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans