How to test Reading permission on certain Directory

Stef-B
Member Posts: 26
I want to count() the number of Files in a certain Directory.
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.
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.
0
Answers
-
This is not possible with basic C/AL. but with some little workarrounds:
for example:
viewtopic.php?f=23&t=30150Do you make it right, it works too!0 -
Thank you Garak
For me it worked with the Codeunit Trick. Just returning the result of the File.Findfirst() works like a charm.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 320 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