Make file and directory removal in Export more robust

Permissions and errors are now checked to somewhat reduce the risk of
accidentally deleting files by specifying an incorrect location.