0

I have decided to locate my data folder for a game I am making in the Documents folder. I am currently going through the quick process of translating from Mac to Windows, where I am having issues finding the document using the same path. I find the path like this:

String path = "c:/Users/" + System.getProperty("user.name") + "/Documents/gamedata/data.txt";

I checked, and it says that it is looking for the path c:/Users/abcdefg/... where abcdefg is my user.name, but the actual path that I want it to find is c:/Users/abcd/ because that is what the folder is called for some reason. I'm not sure why this is happening. The reason I don't manually set path to be the path is because I want my friend to run the game and automatically find the data file.

I have tried: changing the path, trying to find another System.getProperty. I don't want to rename my Users folder because I am worried that might break something.

Let me know if yall know a way to fix this. In the meantime, I might consider moving the folder to be in the root folder, so the path is easily just c:/gamedata/data.txt. Thank you in advance for any help I might get!

CiY3
  • 134
  • 10
  • just use `System.getProperty("user.home");`? – dan1st Dec 20 '21 at 17:37
  • 2
    Did you try `System.getProperty("user.home")` or method [getenv](https://docs.oracle.com/en/java/javase/12/docs/api/java.base/java/lang/System.html#getenv(java.lang.String)) ? Maybe `System.getProperty("java.io.tmpdir")` is appropriate? – Abra Dec 20 '21 at 17:37
  • user.home seems to work. Thank you everyone. – CiY3 Dec 20 '21 at 22:38

0 Answers0