views:

1577

answers:

2

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 the odd thing is, I can create the file without any exceptions. Furthermore, another program can read the file I've created. The thing is, in Windows Explorer, the file doesn't show up at all!

Show hidden files you may be thinking, but no, I've got that option turned on.

I've also found out about 'super hidden files' in Vista, so I've turned that option on and I still can't see the file! Maybe I haven't edited my registry correctly - I can only assume the file is super hidden - where else could it be?

Now the problem is that I'm creating an html file and the when I fire up a browser, it can't see the html file because it's super hidden.

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

+6  A: 

You are most likely a "victim" of folder redirection. When UAC is enabled, any writes to Program Files is redirected to somewhere else when you're not running the program as an administrator.

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

The proper fix, of course, is to not write to Program Files in the first place. Instead, use somewhere in the user's home directory (the exact location you should write to depends on the purpose of the app).

Michael Madsen
A: 

I believe that update 10 might have changed this behavour. I know the reimplemented a lot of the browser stuff to work better with vista. I'm not 100% certain though but I suggest you take a look.

John Burton