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
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.
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;
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156