Java File.canWrite () for Vista and super hidden files

I have some code that effectively does this:

File file = new File("C:\\Program Files (x86)\\Something\\fred.txt");
System.out.println("file.canWrite() = " + file.canWrite());

      

It prints true. Now, which is weird, I can create the file without any exceptions. Also, another program can read the file I created. The fact is that the file is not displayed at all in Windows Explorer!

Show hidden files you might be thinking of, but no, I have this option.

I also learned about "super hidden files" in Vista, so I turned this option on and I still can't see the file! I may not have edited my registry correctly - I can only assume the file is hidden - where else could it be?

Now the problem is that I am creating an html file and when I start the browser it cannot see the html file because it is super hidden.

How can I prevent Java from creating a super hidden file? This is running under JRE 6 update 6.

+1


source to share


2 answers


Chances are you are a victim of folder redirection. When UAC is enabled, any entry in Program Files is redirected to a different location when you are not running the program as administrator.

You should find your file in C: \ Users \ <user name> \ AppData \ Local \ VirtualStore \ <insert> \ <expected> \ <path> \ <here>.



The correct fix, of course, is not to write to Program Files in the first place. Use somewhere in the user's home directory instead (the exact location you should write down depends on the purpose of the application).

+9


source


I believe update 10 may have changed this behavior. I know I have tweaked a lot of browser stuff to work better with Vista. I'm not 100% sure though, but I suggest you take a look.



0


source







All Articles