我想将 Dir“Dir1”重命名为“Dir2”。
但如果“Dir2”退出,那么我想将“Dir1”文件移动到“Dir2”。C:\Artwork\Dir1 C:\Artwork\Dir2 用于重命名
Files.move(path, path.resolveSibling("NewName"))); //Worked Ok
对于已经存在的目录,我尝试了
Path source = Paths.get("C:\\Artwork\\Dir1");
Path newDir = Paths.get("C:\\Artwork\\Dir2");
Files.move(source, newDir,StandardCopyOption.ATOMIC_MOVE); //Throwed AccessDeniedException
Files.move(source, newDir,StandardCopyOption.REPLACE_EXISTING); //Throwed DirectoryNotEmptyException