Problem Finding Record in File Table
matttrax
Member Posts: 2,309
This doesn't lend itself to an easily searchable solution as File, Record, and Table are a little too common on these forums 
If I have this code:
But if I have this code:
Am I missing something about the File table? Can I not filter on Name to see if the file I want is there? I've tried SETRANGE, SETFILTER, and all manner of filter strings, but cannot get the second example to work.
Thanks for the help.
If I have this code:
FileRec.SETRANGE(Path, 'C:\');
FileRec.SETRANGE("Is a File", TRUE);
IF FileRec.FINDFIRST THEN
REPEAT
IF FileRec.Name = 'XXX.ext' THEN
MESSAGE('Found It!!');
UNTIL FileRec.NEXT = 0;
it will display the message.But if I have this code:
FileRec.SETRANGE(Path, 'C:\');
FileRec.SETRANGE("Is a File", TRUE);
FileRec.SETRANGE(Name, 'XXX.ext');
IF FileRec.FINDFIRST THEN
REPEAT
MESSAGE('Found It!!');
UNTIL FileRec.NEXT = 0;
it will not find any records and nothing is displayed.Am I missing something about the File table? Can I not filter on Name to see if the file I want is there? I've tried SETRANGE, SETFILTER, and all manner of filter strings, but cannot get the second example to work.
Thanks for the help.
0
Comments
-
1. don't use findfirst for an loop ;-)
2. try this:FileRec.reset; FileRec.SETRANGE(Path,'C:\'); FileRec.SETRANGE("Is a File",TRUE); FileRec.SETfilter(Name,'@XXX.ext'); //or @*xxx.* for all files with xxx in his name if FileRec.FINDset then begin REPEAT MESSAGE('Found It!!'); UNTIL FileRec.NEXT = 0; end;
RegardsDo you make it right, it works too!0 -
I wasn't originally using a loop, so that's why the FINDFIRST was still in there. I was only expecting one record to be returned.
I have to say, I am really confused. I know the @ ignores capitalization. But I even copied the entire file name directly from Windows explorer and tried to filter on that and got nothing. Yet with the @ it works.
Why does '@XXX.ext' return a record when 'XXX.ext' does not and the file name is actually 'XXX.ext' ?? ](*,)0 -
So I decided just use the File.EXISTS command, but I'm still curious as to why you have to use the @ for the previous example to work.0
-
FileRec.SETRANGE(Path, 'C:\'); FileRec.SETRANGE("Is a File", TRUE); IF FileRec.FINDFIRST THEN REPEAT IF FileRec.Name = 'XXX.ext' THEN MESSAGE('Found It!!'); UNTIL FileRec.NEXT = 0;Mattrax,
logically the above code should work, but the file name is case sensitive so try to give the file name exactly as same as stored in the FileRec table. hope it works then or alternatively use FILE.EXISTS(FilePath) as a last option... 8)0 -
As I stated before, I used the exact file name. Compared the lengths to make sure there weren't some weird characters in there that I couldn't see for some reason. Also compared each character of the string.
So if the field contains X, a filter of X does not work, but @X does.0 -
on a local database (without a serverconnection) it works without the @.
On a serverconnection i found out for some years that i must use the @. Why? Never searched for the reason ..... Sorry. Maybe it's depending on the serversetting / databasesetting on the server (Codepage).Do you make it right, it works too!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions