Genius 49 Share Posted April 19, 2017 I'm making a save/load preferences feature on one of my scripts, and want to make it compatible with Mac machines as well. String path = ("C:\\Users\\" + System.getProperty("user.name") + "\\DreamBot\\Genius Scripts\\"); ^This will only work on windows, of course. The full snippet creates the directory if it doesn't exist, and saves a preferences text file that the "load" part of the snippet reads to fetch user settings. Since I'd like it to work with Mac machines as well, I would need someone with a Mac to tell me the "DreamBot" folders path on their machine. I read something about "~" is the C drive equivalent? Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
Neffarion 486 Share Posted April 19, 2017 I'm making a save/load preferences feature on one of my scripts, and want to make it compatible with Mac machines as well. String path = ("C:\\Users\\" + System.getProperty("user.name") + "\\DreamBot\\Genius Scripts\\"); ^This will only work on windows, of course. The full snippet creates the directory if it doesn't exist, and saves a preferences text file that the "load" part of the snippet reads to fetch user settings. Since I'd like it to work with Mac machines as well, I would need someone with a Mac to tell me the "DreamBot" folders path on their machine. I read something about "~" is the C drive equivalent? Any help would be greatly appreciated. You can use this. It will work on mac, linux and windows // this returns "C:\Users\YOUR_USER\DreamBot" or the equivalent in other operating systems public static String getStorageDirectory(){ return System.getProperty("scripts.path").replace(File.separator + "Scripts",""); } Link to comment Share on other sites More sharing options...
Genius 49 Author Share Posted April 19, 2017 You can use this. It will work on mac, linux and windows // this returns "C:\Users\YOUR_USER\DreamBot" or the equivalent in other operating systems public static String getStorageDirectory(){ return System.getProperty("scripts.path").replace(File.separator + "Scripts",""); } Ahhhh I didn't know something so simple existed! Thanks a lot Neffarion!! Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.