Mac/Windows path

Currently to read or write files I am having to use

            if (Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.WindowsEditor)
            {
                saveGameFile.Load(Application.dataPath + "\\USERDATA\\" + curPlayer + ".xml");
            }
            if (Application.platform == RuntimePlatform.OSXPlayer)
            {
                saveGameFile.Load(Application.dataPath + "/USERDATA/" + curPlayer + ".xml");
            }

Which is getting annoying and long because I have to include this anytime I want to transverse a different directory. Is there a universal way to type application paths so I don’t have to do the \ and / ?

Path characters in .NET are just / for everything, regardless of Mac or Windows. If you wanted to use \ for Windows anyway, you could define a path char depending on the platform, and use pathChar instead of hard-coding / and \ everywhere.

–Eric

oh, well that saves me alot of time. I don’t know where I got using \ for windows and / for mac. Thanks!

Actually the / part has nothing to do with .NET I think, since Windows NT4 or at latest 2000, windows has always supported / instead of \ in the paths. the \ enforcement only existed on the “insecure perma-BSOD” media OS aka Win95, 98 and ME and naturally the 3.1 and earlier versions

I’d like to know whose bright idea it was to use a common escape character as a path character in the first place…

–Eric

“file:///”+“C:/Users/m/AppData/LocalLow/DefaultCompany/test_heart\myfile1.wav”

when I use this path for www, I usually got nothing, why?

As an aside, take a look at System.IO.Path.PathSeparator.

thanks,