Create a text file in %AppData%/AppName

When I try

File.WriteAllText("%AppData%/AppName", arg2);

The file is created in UnityProjects/AppName/%AppData%/AppName, not C:/Users/Username/AppData/Roaming/AppName/.

Thanks for help.

I don’t think things like %appdata% are expanded out when using file functions, but I’ve admittedly never tested that. You can build the path with Application.persistentDataPath. That will work consistently across platforms as well.