No, what you said makes no sense. If you have saved it, it is saved. However it makes not much sense to store something in the Resources folder as this only exists in the editor when you work on your project. You can not change any assets in the resources folder from runtime when your game is built. So what exactly are you trying to do?
If you want to store a file at runtime for later use, you have to use the persistentDataPath.
edit
If you actually do this from an editor script in order to save the file in the project, you have to tell the AssetDatabase that the file has changed. Usually AssetDatabase.Refresh should work. If not using AssetDatabase.ImportAsset on the asset path should force a reimport of the asset. Note that the asset path has to be a relative path to your project root. So it has to start with Assets/... and has to use forward slashes.
The later fixes the problem but maybe I am taking the wrong approach.
I basically have a list of questions that can be added too later (or deleted). I am using the persistentDataPath to get to the resources folder. Can I save it in another folder in assets and that will be okay?
I’m not sure what you mean by “later”. Do you mean after the game has been build? Or do you mean while you are developing the game? Assets are only available as files inside your project folder. This does not exist at all once your game is build. Assets in the resources folder are read only as they are compiled into the asset database of your project. The presistent datapath is a storage location for the given platform where applications can store information that should persist. If you want to have a file that the user can edit / replace, you can ship the initial version of the data as a Resource and extract it into the persistent datapath in case the file does not exist there yet. Otherwise your application would just read / write the file from the persistent path.
Note that there’s also the StreamingAssets path. On most platforms files in those folders are read and writeable. However on some platforms like WebGL or Android this folder is not an actual folder and those are read only on those platforms. You also can not use the System.IO methods on that folder on those platforms. So using the persistent data path is generally the best solution when you want to read / write those files at runtime or if you want to enable the user to change / replace the file in their game. Of course there are other platform dependent solutions. For example for windows builds using the streaming assets folder may be simpler as the files would be shipped right next to your game.
Keep in mind that those are just methods provided by Unity for convenience. The abstraction of the persistent data path should work on pretty much all platforms (including WebGL where the local storage of the browser is used).
Just popped in to see how someone ‘physically opens’ a file in Unity…
Snarking aside - in general terms, before you can write to a file, it must
exist and
be open and
ready to be written (write privileges)
It is on you to ensure that all above conditions are met. Once you are done writing, you usually
must close it
(which usually causes the file cache to be written to storage and the file system to relinquish exclusive access.
So if, as you say, the file exists (you want to append data) you can’t (usually) simply call File.Write and expect the data be appended. You need to open the file with write permission, position the ‘file position’ at the end, and then add the data, and then close the file so the changes are applied. An alternative is to construct the entire file (existing and appended data) in memory, and replace the entire file each time, but essentially the steps are the same, except you create a new file when you open for write (usually, the procedure is to create a new temp file, write everything, and when that was successful delete the original and rename the temp to the original’s name).
Here’s also a link to how to do this with a link to an asset text file in Unity
Note that the file does not need to exist. When you open a file for writing, the file is usually created at that moment. Also you rarely append to files. This is mainly used for text files / log files. Whenever you open a file in any application and you resave the file, the whole file is overwritten.
File.WriteAllText does all your mentioned steps at once. It will open the file for writing, replaces the file in case it already exists, writes all the text and closes the file at the end.
Physically open I just meant to open it from notepad in finder. Sorry for the poor wording. I have realised now by opening in finder the unity editor must have automatically refreshed the asset.
My issue is well put by Bunny as I was using the persistent data path but navigating to within my assets folder. I just needed to save it outside the assets folder!
Using the ImportAsset does however stop the problem happening in the editor but is a false solution as it only works in editor.