- Home /
File exists not working applicationDataPath
I'm using a simple save load thing, Upon an event a file is moved to the Saves folder and deletes the previous one, before adding application.persistentDataPath it worked fine in game but not in the build after it doesn't work on either, The scene should start and detect if a file exists, if not it will not run anything and if it does exist it will run the scene. so any idea whats wrong with it?
IEnumerator Start () { Start: if (System.IO.File.Exists (Application.persistentDataPath + "Assets/Saves/original")) { SceneManager.LoadScene (72); } else { yield return new WaitForSeconds(2); goto Start; } } }
Edit: Before anyone asks Yes I have checked the saves file for original
Answer by toddisarockstar · Apr 30, 2020 at 06:18 AM
the path is going to a little different depending on weather you are running from inside unity or a real build. this would help:
if (Application.isEditor)
{
print("We are running this from inside of the editor!");
}
i would suggest looking at your path result and adjust accordingly. some simple string twiddling might help you out. kinda guessing something like this?
string path = Application.dataPath.Replace("Assets/","/")+"YourFolder/";
Your answer
Follow this Question
Related Questions
System.IO.File does not contain a definition for 'WriteAllLines' 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
C# How to read and cache text file data? 1 Answer
Multiple Lists to CSV in C# 0 Answers