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 :
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

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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.

  • Verified answer
    Community Member Profile Picture
    on at

    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;

  • Community Member Profile Picture
    on at

    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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans