Why does DirectoryInfo.GetFiles() get the FileInfo of a file without user permission?

2 weeks ago 9
ARTICLE AD BOX

Here's the code:

DirectoryInfo di = new DirectoryInfo("C:\\Users\\Public\\Test"); FileInfo[] infos = di.GetFiles();

This code does not throw an exception, and gets the FileInfo of a file in that directory (test.txt), which I have denied the user permission to.

The user was denied all permissions so that if I (using that account) click on the file, it does not open.

If denying all permissions still lets GetFiles() get this file, what is the case where GetFiles() will fail? In other words, how do I make a file cause GetFiles() to throw an exception?

Read Entire Article