Peculiar behaviour of table 2000000022 File

rocatisrocatis Member Posts: 163
There's quite a lot of messages in this forum regarding how to utililize the virtual table 2000000022 File.

What none of them seem to address is the fact that the behaviour of this table is downright weird.
f: Record(2000000022)

f.SETRANGE(Path,'C:\Temp');
MESSAGE('%1',f.ISEMPTY);
This works if the folder C:\Temp exists. But if you try the same code with a folder that doesn't exist, you'll get an error (even though the code shouldn't be able to do this), but even weirder is the fact that if you run the same code again, you don't get an error. Try changing the path name to another non-existing path and you'll get the same error again - but only once.

This is basically known behaviour for the File table (the table content is not refreshed unless you set the Path filter to a folder different to the one you used last) but how to avoid the error codes? Well, we need to make sure that the code is not run if the path does not exist. This can be accomplished using EXISTS:
IF NOT EXISTS('C:\Temp\nul') THEN 
  MESSAGE('Yes')
ELSE BEGIN
  f.SETRANGE(Path,'C:\Temp');
  MESSAGE('%1',f.ISEMPTY);
END;
Brian Rocatis
Senior NAV Developer
Elbek & Vejrup

Comments

  • kinekine Member Posts: 12,562
    Still, you can have problems with folders which exist but you do not have permissions to read...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • rocatisrocatis Member Posts: 163
    kine wrote:
    Still, you can have problems with folders which exist but you do not have permissions to read...
    That's true. Still, the guys at Microsoft need something to do at the weekends :wink:
    Brian Rocatis
    Senior NAV Developer
    Elbek & Vejrup
  • krikikriki Member, Moderator Posts: 9,110
    [Topic moved from 'NAV 2009' forum to 'NAV/Navision' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.