• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with security and File class

jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wrote the following program just to practice using the File class, and also recursion. It searches through a designated drive (D:\ in this case, will be modifying it to search all drives), and returns the path of the file designated by the command-line argument:

It works fine, except for the System Volume Information folder, or any other folder that is set just for the System user. When the program hits a folder that is basically restricted in acess to System, I get a NullPointerException. If I change the folders persmissions to Everyone Read or above, program works fine.
I've tried using the canRead() method so that if the program hits something that can't be read, it passes over it. However, the program returns true, saying that this folder can be read. It seems that there is a conflict between what the program views as read permissions, and what Windows security is allowing.
Has anyone seen this, or knows of a way to alter the program to bypass folders and files such as these?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic