Hi, im developing a Android/iOS videogame in Unity. I need to delete a file, i have the path. Im using the next code:
public void DeleteElement (string path)
{
File.Delete(ruta);
}
When I delete a file in android, I can see from the android file browser that it is no longer in the folder where it was before, but when, from my Windows computer, I check that folder with the File Explorer, it is still there, although it can not be opened.
Why is the file not completely deleted? How do I safely remove it?
So you are deleting the file in the Windows file system? Or are you using Windows File Explorer to browse your Android file system. When you exit Unity, is the file still there?
I’m using Windows File Explorer to browse the Android device file system and check if the Unity app actually deletes the file using “File.Delete(path)”. In Android device file system the file inst there. In Windows File Explorer I still see the file although it is unusable. The file is in Movies folder of the Android file system.
It Looks like the Android file System keep the files deleted and will removing them by restarting the device or some other way. I will not worry about that anymore. Thanks
Usually, before the deleted file being overwritten, it will be still saved. I think you need to use android data eraser tool to help you delete the file in Android permanently.
I know this is old but you have not updated the Media cache in Android. Thus the real file system has not file but since Windows reads from a cache, since you didn’t tell Android to dirty the cache, Windows still thinks there is a file there.
Restarting your device will dirty the cache and all will be well.