Can't remove a file

Godot Version

4.4.1-stable mono

Question

They say it’s possible to delete a file with using “DirAccess.remove(path)”, but I have some troubles with it:
DirAccess.remove(UserData.SAVE_PATH) # Removes the save file
изображение

But if I create an instance, I’ll get another error
DirAccess.new().remove(UserData.SAVE_PATH) # Removes the save file
изображение

You would have to open a directory to use .remove on it, the static version is DirAccess.remove_absolute.

1 Like

Like DirAccess.open(directory_path).remove(UserData.SAVE_PATH)?

Thanks, this worked DirAccess.open("user://").remove("SAVE.cfg") or DirAccess.remove_absolute(UserData.SAVE_PATH) # UserData.SAVE_PATH = "user://SAVE.cfg"