Moving (or copying) a file from outside the build to the build's resource folder during runtime.

Hi,

Is this possible? Any tips?

I’ve looked at -
FileUtil.CopyFileOrDirectory and FileUtil.ReplaceFile. Will one of these do the trick?

Thanks.

You can’t actually do this. The resources folder gets compiled into the binary data of the game.

You can do something similar with asser bundles and the streaming assets folder on some platforms.

Thank you for your response. Is there a way I could copy the file and then save it to the Resource folder? I’ve written and saved files to the resource file before. So is there a way to grab a file from outside the build (on macOS), load it into the Unity build and then save it to the Resource folder?

No. Like BoredMormon said, once the game is built, the Resources folder is turned into a packed archive file and you can’t write to it. You can load files from anywhere though, using System.IO.File, and using the correct paths for the platform you’re running the game on. Or you can use AssetBundles.

1 Like

Oh right sorry, I haven’t written a file to the Resource file, what I did before was create a folder on the device using Application.persistentDataPath, created a folder there and saved a file to it. Thanks for your help guys.