Write to text file in folder of executable

im trying to use system.io to write to a text file. That is working… but i want to make it write to the file in the folder of the executable… so instead of having to put a full file path it will just check the root folder dynamically.

	if (System.IO.File.Exists(@"	ext.txt")) { 
        System.IO.File.AppendAllText(@"	ext.txt", "my string..."); 
	}

this doesnt work… obvisouly. How can I make it work?

@thornekey My answer is probably way to late, but I wanted to do the same thing and ended up doing it so:

string file=Application.dataPath;
string[] pathArray = file.Split('/');
file="";
for(int i =0;i<pathArray.Length-1;i++){
	file+=pathArray*+"/";*

}
file+=“data.json”;
It’s probably not the best way, but it works.

Typically this is bad practice. Most operating systems want you to write in the documents folder (or equivalent). This can be accessed with Application.persistiantDataPath.

However if you know what you are doing then check Application.dataPath will work.