No matter what, it won't delete

I had some issues way back with trying to modify files in windows-managed dirs, but it was a couple of years ago (on Vista). I can’t seem to find the info I used back then though… It had something to do with that some files are not what they seem. They are actually located somewhere else and managed by windows so that you can get inconsistencies. I might be very wrong though since I can’t find the info about it now.

Unless user.home is set to something really strange, it seems unlikely you’d run into folder virtualization problems, since the user home folder is where virtualization redirects to. Usually it only bites you if you try writing to %ProgramFiles%

Thanks for all replies. I can just give up user.home and use other path.

Put a breakpoint on the line calling delete(). Then see if it allows you to delete the file while the program is paused. You may also want to try renaming/moving your file.

What’s wrong with that? (They’re not magic numbers either. They’re more like a UID.)

Don’t do that. Unless the user explicitly specifies their own path, then just treat every folder that’s not the temporary file directory or under the user’s home folder as if they were read only. If the other path works (on your computer), you’re probably just sweeping a real problem under the rug.

I’ve been hit by this problem before a few times and it always turned out to be my own fault, usually caused by creating a stream an not reliably closing it.
If you have to call System.gc() to make it work, than that’s a sure sign you’re doing something wrong (at least for me that was always the case).

Could you post the code that created the file, and the code that deletes the file?