delete a directory in code

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lewis glasgow

i have i folder in the user:// path but this does not work anyone got any good work arounds

var dir = Directory.new()
dir.remove("user://level1")
:bust_in_silhouette: Reply From: Wakatta

Workaround

Use OS.execute() with the system’s default removal command rmdir for unix and windows type systems

Answer

Honestly a workaround is unnecessary since Directory.remove() works just fine. There are a couple things to note.

  • You must have read/write access
  • The directory must be empty

thank you i did not know the directory had to be empty

lewis glasgow | 2021-09-01 10:56