Delete an empty directory

I’m trying to delete a directory but first deleting its contents then deleting the folder itself. However, when i use Directory.Delete(), it doesn’t delete the directory and gives me a console warning saying: [quote]
A meta data file (.meta) exists but its folder ‘Assets/Saves/Test’ can’t be found, and has been created. Empty directories cannot be stored in version control, so it’s assumed that the meta data file is for an empty directory in version control. When moving or deleting folders outside of Unity, please ensure that the corresponding .meta file is moved or deleted along with it.
[/quote]

Is there a way of stopping this happening?
Thanks

Your answer is right there in the warning. Delete the .meta file corresponding to the folder you want to delete.

1 Like

You should delete the folder via Unity - Scripting API: AssetDatabase.DeleteAsset which will automatically handle removing the .meta file for you.

1 Like