In my Java app I find the APPDATA folder and then attempt to create my own subfolder:
if (System.getProperty("os.name").startsWith("Windows")) {
settingsDir = System.getenv("APPDATA") + "\\MyApp\\";
if (!(new File(settingsDir)).isDirectory()) {
if (!(new File(settingsDir)).getParentFile().mkdirs()) {
Error("Failed to create directory " + settingsDir);
}
}
}
On Windows XP this fails, saying the folder could not be created.
The hidden Application Data folder is read-only, and apparently this cannot be changed.
Could this be the reason why creating the new folder fails? If so, what would be the typical way to create a new folder in the APPDATA folder from Java?