After working for a while, Unity got stuck compiling the shadow caster shader and never finished. Had to force close. Ever since then using Application.persistentDataPath with File.Exists and File.ReadAllText fails. I’m not sure what to do outside of recreating the project, which would really suck.
Nothing in the read file process changed, except the new logging, this just started happening after the crash while I was working on something else. It seems like whatever interaction File and Application.persistentDataPath have they are no longer working when used together now via File.Exists or File.ReadAllText and I have no idea why.
I’ve tried using Path.Combine for the paths, didn’t do anything different.
I’ve tried using Path.DirectorySeparatorChar, didn’t do anything different.
Logging:
reading save: test_009
fileName: test_009.json
persistentDataPath: C:/Users/user/AppData/LocalLow/company/project
filePath: C:/Users/user/AppData/LocalLow/company/project/test_009.json
File Exists: False
Code:
try
{
Debug.Log("reading save: " + saveName);
string fileName = saveName + saveFileExt;
Debug.Log("fileName: " + fileName);
string persistentDataPath = Application.persistentDataPath;
Debug.Log("persistentDataPath: " + persistentDataPath);
string filePath = persistentDataPath + "/" + fileName;
Debug.Log("filePath: " + filePath);
Debug.Log("Exists: " + File.Exists(filePath));
if (File.Exists(filePath))
{
Debug.Log("file exists");
string loadData = File.ReadAllText(filePath);
if (loadData == "") return;
***Code continues ***
directory and files: