Write To A Text File Inside Of The Application

I Need A Way To Write A Text File Through Unity In C#, That Saves It To The Inside Of The Application On OS X(By Inside I Mean Package Contents). I Have Tried

using System;
using System.IO;
using UnityEngine;
using System.Collections;

public class WriteText : MonoBehaviour {

	void Start() {
		System.IO.File.WriteAllText("ScurgeOfTheShadows.app/Highscore.txt", "Hello There");
	}
}

Yet It Says It Is An Invalid Directory, Maybe Im Just Not Sure How To Save To The Txt File Inside Of An App, Or Maybe System.IO Is Not What I Should Be Using. All Help Is Appreciated!

I don’t think you can use the System.IO methods because the directory is different based on what platform the game is for. You should use a Text Asset and you can read and write from that. You find it by grabbing the filename without the txt extension and using the text property of the asset. The file also needs to be in a folder named “Resources”, if you don’t already have one just make one.

TextAsset asset = (TextAsset)Resources.Load("Highscore");

String textFromFile = asset.text;

asset.text = "What you want to write to the file";