- Home /
How can I access an external file within the same folder as the built .exe?
So I plan on building my game (which will run on Windows, Mac, and Linux) and then putting both the data folder and the exe folder into a new folder, which can be called "Game". But if I add a file in after, called "saves", how can I save my data to this folder without using the whole file path?
PlayerPrefs won't work for me, neither will any other in-unity saving type. Also, I'm using C#.
Can't you put this folder in the Resources folder and use unity's Resources.Load etc
Well as long the location is relevant to the game location you can find it with picking up the Application.dataPath ,which will point on your data folder and then you can work your way backwards to the parent folder and then pick up the wanted file. But if you create the save file on runtime means you already know the location of it. Cheers.
Answer by T-A-M · Feb 08, 2018 at 01:34 PM
I figured it out.
saves = new StreamReader((System.IO.Directory.GetCurrentDirectory()) + "/saves.txt");
realsaves = (saves.ReadToEnd());
Answer by Play_Edu · Feb 08, 2018 at 09:33 AM
Without IO i think file can't be access . Try scriptable object if work for you.