Unable to delete a properties file

前端 未结 2 452
轻奢々
轻奢々 2021-01-21 09:04

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\")         


        
2条回答
  •  余生分开走
    2021-01-21 09:37

    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
    }
    

提交回复
热议问题