I have to delete a property file from the path specified. I used the following code:
File f1 = new File(\"C:\\\\Equinox\\\\UIDesign\\\\root\\\\root.properties\")
There are a couple of reasons why File.delete()
can fail:
The last one could be your own fault, if you've opened a FileInput/OutputStream for that file and forgot to close it.
I agree with Michael, his answer makes a lot of sense. Just a comment on your code, you should be doing the following to catch all possible errors and notify the user accordingly:
try{
File f1 = new File("C:\\Equinox\\UIDesign\\root\\root.properties");
boolean success=f1.delete();
if(!success){
// Notify user that the file
}
catch(SecurityException ex){
// No sufficient rights to do this operation
}