Java cannot delete file on drive "C: \"
I have the following code:
public Tester()
{
try {
File f4 = new File("C:\\Vase.zip");
System.out.println(f4.exists());
f4.delete();
System.out.println(f4.exists());
} catch (Exception e) {
e.printStackTrace();
}
}
When I run the program, it doesn't delete the file. (If I put the file on drive D and then ask to delete it, it works fine.) So I know it's a permissions property. I am using eclipse. I only started eclipse in admin mode [in windows].
The program is capable of writing and deleting other files, but this one does not work. Can anyone help me figure out how to solve this?
+3
source to share
2 answers
Maybe it is open in your archiver.
Or somewhere else.
Or (unlikely, but possible) - a process has ended, but the system is still holding it on behalf of that process.
- Close all applications (except Eclipse, of course) and try again.
- This 1. doesn't work - try rebooting, open Eclipse and try again.
If that doesn't work - permissions should be a problem.
+1
source to share