Is there a way to lock up a directory with Java?
-
08-10-2019 - |
Question
My app creates a directory(file folder) on C:/ drive, since I don't want to expose all the data in it, and I don't want to encrypt all files in it, I wonder if there is a way to lock the folder up, so only my app can access it, no other person through windows explorer or another program can open the folder, doesn't matter if my app is running or not, is it doable ?
Solution
Nope, operating systems just don't provide this type of facility. You can look at file locks (http://en.wikipedia.org/wiki/File_locking) but those are intended to prevent "concurrent access" not this sort of "lock". With that said, you should ask yourself what are you trying to do here, is it securing information (encrypted file) or preventing accidental configuration changes (hiding the directory)?
OTHER TIPS
This is inherently impossible.
There is nothing that your program can do on the user's machine that he cannot do himself. (possibly aided by a decompiler and a debugger)