Saving a file on iOS? (tried many fixes, still not working)

Hello guys. I created a text file that I want to save. However, on iOS it keeps giving me a DirectoryNotFoundException.

First, according to the stuff I’ve read online, I made a variable set up like this:

FileLocation=Application.dataPath.Replace ("MyApp.app/Data", "Documents");

Afterwards, I try to create my file like this:

FileInfo t = new FileInfo(FileLocation+"/"+ FileName);

According to the Debug.Logs I’ve put, the location where I’m trying to save my file is this:

/private/var/mobile/Containers/Bundle/Application/7CEB4042-4143-4E25-8E49-8D7B92FD28E6/Documents/SaveData.nom

However, I get the following exception whenever I try to save/create that file:

DirectoryNotFoundException: Could not find a part of the path “/private/var/mobile/Containers/Bundle/Application/9B8A0040-90B5-4BA1-A568-9F999FF25122/Documents/SaveData.nom”. at System.IO.FileStream…ctor (System.String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean anonymous, FileOptions options) [0x00000] in :0

Why is that? According to what I’ve read, the “Documents” folder is where I can save things. Has this changed in the most recent version of XCode or something?

Please help me out. I have been searching for answers but haven’t found anything at all that can fix this.

So I would suggest doing this serialize thing that I did. Serialize and deserialize. basically you store things into an xml file. In this system, whenever you need to get something stored or save something do the following:
Read Stored Data: Get the variable’s contents
Save Data In File: Set the variable’s contents and then call the Save() method
To understand this, watch this video:

also instead of naming the class Helper like that guy did, name it Utils short for Utilities

I just realized this thread is from 8 years ago. Rest in peace problem.