How to test Reading permission on certain Directory

Stef-BStef-B Member Posts: 26
I want to count() the number of Files in a certain Directory.
IF EXISTS(T_Path+'nul') THEN BEGIN
   R_File.RESET;
   R_File.SETRANGE(Path,T_Path);
   R_File.SETRANGE("Is a file",TRUE);
   I_NumberOfFiles:=R_File.COUNT();
END;
Everything works fine up to the point where the Count is issued.
Some users do have the permission to read that certain path, and some users don't.
For those user who don't have access a message appeas saying "The os doesn't allow acces ...".

How can I test the permission and avoid the message. The Exist test doesn't help me, since the path really exists and Exist always gives TRUE in return.

I hope you understand the problem.

Answers

  • garakgarak Member Posts: 3,263
    This is not possible with basic C/AL. but with some little workarrounds:

    for example:
    viewtopic.php?f=23&t=30150
    Do you make it right, it works too!
  • Stef-BStef-B Member Posts: 26
    Thank you Garak

    For me it worked with the Codeunit Trick. Just returning the result of the File.Findfirst() works like a charm.
Sign In or Register to comment.