I am finding an issue while deleting a folder from Java. I used following commands without luck. However, I am able to delete folder through command prompt using Windows 8.1:
String command1="rd /s /q"+Path;
String command2="rmdir /s /q \""+Path+ "\"";
String command3="del /q \""+Path+ "/*\"";
The exception I get in all the three cases is:
java.io.IOException: Cannot run program "rmdir": CreateProcess error=2, The system cannot find the file specified at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048) at java.lang.Runtime.exec(Runtime.java:620) at java.lang.Runtime.exec(Runtime.java:450) at java.lang.Runtime.exec(Runtime.java:388)
Using Code:
try {
Process process = Runtime.getRuntime().exec(command);
} catch (Exception e) {
e.printStackTrace();
}
P.S.: Its a locked file