所以,我正在创建一个游戏,需要创建目录来存储所有用户的数据并保存和诸如此类的东西.如您所见,我需要在名为"[WarDungeon]"的用户的Application Data文件夹中创建一个文件夹,在那里,我将存储其他文件夹,例如level,bin,sprite等.
我对使用Mac OS和Linux不太感兴趣,因为我想让%appdata%文件夹与Windows一起使用.
这是我的代码:
public FileManage() {
gamePath = System.getenv("APPDATA") + "[WarDungeon]";
gameLevelPath = System.getProperty("user.home") + "\\Local Settings\\ApplicationData\\[WarDungeon]\\level";
gameBinPath = System.getProperty("user.home") + "\\Local Settings\\ApplicationData\\[WarDungeon]\\bin";
File createDir1 = new File(gamePath);
createDir1.mkdir();
System.out.println("First test passed.");
if (createDir1.exists() == true) {
System.out.println("First directory created!");
}
}
Run Code Online (Sandbox Code Playgroud)
我该如何解决?
提前致谢, :)