Does making a directory with System.IO work with Mac OS systems?

I want to make a game (which I am not saying what its about to avoid being copied) and part of it is making a save file, I want to make the game for Windows and Mac OS systems, but what if I put a C:? path on it, will it work on Mac? I have personally never tried Mac OS, but from my research they don’t use letters to name their drives. So will something like ‘C:/afolder’ would work on Windows if the path existed, of course. But will it on Mac? Should I just use if OS = Mac? I want to save lines of code and not have to take time doing if OS = Mac and all that. Thanks for the answer like always (if you did, of course).

No, it won’t work on Mac, because C: doesn’t exists. It is also bad approach on Windows, because if non-admin user plays your game, you may not have a permission to create a folder in C: as well. It is also bad to pollute users hard drive.
Your game should be saving files in dedicated directories. Application.persistenDataPath gives you a writable directory for your game.

1 Like

To clarify this a little, System.IO.* stuff can be used on MacOS. But, as you noted, the paths are not the same, so you won’t be able to save to “C:\Somewhere”.

As Aurimas mentioned, asking Unity for Application.persistentDataPath should work, since that gives you a correct path for whatever platform the build is playing on, as well as giving you a more appropriate place to put arbitrary files than a user’s root drive, which you likely won’t have permissions to write to anyway.