Refresh StreamingAssets directory

I’m making a game which involves the player coding in lua, so naturally I need to allow them to create and edit .lua files. I have a system for file management in place right now, storing .lua files in the StreamingAssets folder, and I have a script attached to my UI made that displays all of the .lua files in the folder, and allows for the creation and deletion of said files.

This all works fine, except that when a file is deleted in the same instance it is created (i.e. play game, create file, delete same file), the file cannot be accessed because while it is technically there, the streaming assets folder is not refreshed. It works as expected if I manually refresh the streaming assets folder while the game is running.

I know that AssetDatabase.Refresh is obsolete outside of the editor. Anyone have any methods they use to refresh a folder/files that work in the built game?

I’m working in C# by the way, here is some of the code commented up and I can give you more if you need it: Create/Delete file - Pastebin.com

Thank you for any advice you can spare!

Try using Application.persistentDataPath instead? StreamingAssets really isn’t meant for players to store anything - it’s just for files to be bundled up with your app, and would probably get overwritten anytime the application is updated.

Woah, awesome! I had heard mentions of this before and tried it, but obviously not in the right way. And just to make sure, this method will work in the built game, on any platform (I only need desktop platforms actually)? Thanks so much!

I know it works on Android, iOS, and desktops. Can’t guarantee other platforms.