Can't write to txt file after inno setup. ( Play and after Build on unity : it works )

Hello Guys !

i have an issue that i really don’t understand, i am totally stuck.

I have a game that the score is update when you finish the game and it is store in a txt file.
and i use the txt file to update progression bar o something else.

the data is save in a txt file that is already create in the resource folder in unity and i access it in the script by this line :

static string path = Application.dataPath + “/Resources/FG_S_DataFile.txt”;

On play : it works no problem : score is update, progression bar is ok etc.
After Build : same, it works.

After that, i create an exe with Inno setup, i try to play and that not work. at the end of the game : no scoreboard, no update.
after a few test, it seems that mygame can’t found the txt file or… can’t write on him…

if you have any idea it would be nice ! i just don’t know where else to go !
thanx a lot and have a nice day.

You cannot (generally) write to files in Application.dataPath.

Are you perhaps looking for Application.persistentDataPath ?

Hello !
Thank you for your answer !
I tried yes with persistentDataPath, and had the same prtoblem :frowning:

But when you say that we can’t write to files in App.dataPath, what i don’t understand it’s why it works on play and on build but not when i pass the game to inno setup :frowning: !

Since you can reproduce, you could create a debug build that writes Debug.Log output to a UI text field and go through the Inno setup and find out where it’s failing.

oh… that is smart.
i will do that. Thanx a lot .

Hello !
Jeff that was a good idea,
an error came up :


So i run the game in Administrator and it works ! ( the app after Inno setup step )

then i try to setup all rights in the ini file before build, ( to allow the games to work corretly without administrator launching ) but that didn’t work.

Is there anything to do to allow the game interact with this ini file without lauching the game in administrator ?
again, Thanx a lot. you were very helpful.


You will likely need to reach out to Inno support, I’m not familiar with the tool.

If you want to modify the data you need to have it in
Application.persistentDataPath.
its the intended location for app modified data that should preiset between runs.
The windows Permmission system is designed to only allow the Administrator to modify a Programm installation.
Application.persistentDataPath is in a user folder and so does not override / change the Programm.
You can still read the ini file on start from the location next to the exe file and the write it over to the new location in Application.persistentDataPath.
Then the file should have user permissions.

2 Likes