Sometimes you encounter problems when trying to delete a folder and its subfolders in Windows (NTFS) and getting the Access Denied error even if your user is member of the local administrators group and you tried to take over ownership by using the file explorer.

In that case you can execute the first or both of the following commands in CMD or PowerShell, provided your user is member of the local administrators group of course, in order to be able to delete the folder and its subfolders.

takeown /F "C:<path of the folder you want to delete>" /R /D Y

# This tool allows an administrator to recover access to a file that was denied by re-assigning file 
# ownership.
# /F filename
# /R recursive
# /D prompt Default answer used when the current user does not have the "list folder" permission on a 
#  directory. This occurs while operating recursively (/R) on sub-directories. Valid values "Y" to 
#  take ownership or "N" to skip.

# If necessary also execute the following command, your account should be a member of the local 
# administrators group.

icacls C:<path of the folder you want to delete> /T /C /GRANT administrators:f

# Displays or modifies discretionary access control lists (DACLs) on specified files, and applies 
# stored DACLs to files in specified directories.
# /T Performs the operation on all specified files in the current directory and its subdirectories.
# /C Continues the operation despite any file errors. Error messages will still be displayed.
# /GRANT Grants specified user access rights. Permissions replace previously granted explicit 
# permissions.

Now you should be able to delete that folder.