Undeletable Folder in java

后端 未结 2 672
终归单人心
终归单人心 2021-01-28 23:32

I tried to create a Undeletable folder using java code. I use the command \"cacls (Foldername) /e /c /d %username%\" in command prompt it worke

2条回答
  •  故里飘歌
    2021-01-28 23:54

    Try this code it works fine.It suits for both file and folder.

    public class Undeletable {
    
        public static void main(String[] args) {
    
            Runtime runtime=Runtime.getRuntime();
            try {
                Process process= runtime.exec("cmd.exe /c  start cacls text.txt /e /d %username%");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        } 
    
    
    }
    

提交回复
热议问题