How to save a .txt file into a specified folder

Hi I’m trying to send and save information to a dedicated folder on my hard drive. Like a username for example.

I’ve actually been able to send the file out. But by default, it goes directly into the project folder.

Any way I can direct the file through a clear path like: Macintosh HD > Desktop > UsernameFolder ???

Any help would be great, thanks!

I think this method might help you

public static bool WriteFile (string path, string fileName, string data, FileMode mode)
	{
		bool retValue = false;
		string dataPath = path;
		try {
			if (!Directory.Exists (dataPath)) {
				Directory.CreateDirectory (dataPath);
			}
			dataPath += fileName;
               try{
			System.IO.File.WriteAllText (dataPath, data);
			retValue = true;
		} catch (System.Exception ex) {
			string ErrorMessages = "File Write Error

" + ex.Message;
retValue = false;
Debug.LogError (ErrorMessages);
}
return retValue;
}

Pass the path and file name you want and data in string format. Filename should contain the extension aswell