I'm making a program that creates a folder using os.makedirs("foo")
.
But when I open Windows 10 files explorer and right click on the new directory that has been created, I noticed that it was not possible to delete the folder without administrator privileges.
So how do you create a folder with the permission to recursively delete this folder ?
I create the directory using: os.makedirs("data/base/{}".format(args[0].text), mode=0o777)
I delete it using:
def delete_class(self, *args):
for root, dirs, files in os.walk("data/base/{}".format(self.clicked_class_to_delete.id), topdown=False):
for name in files:
filename = os.path.join(root, name)
os.chmod(filename, stat.S_IWUSR)
os.remove(filename)
for name in dirs:
os.rmdir(os.path.join(root, name))
shutil.rmtree("data/base/{}".format(self.clicked_class_to_delete.id)
)