Delete Undeletable Files by command line

If you want to upgrade your Windows operating system to Windows 7 and install windows 7 on another partition with windows xp/vista still on hard drive,you will get a big Issue how to Delete Undeletable Files in Windows 7.
Here are two command line syntaxes which can delete undeletable files or directories in windwos 7.

For Files:
takeown /f file_name /d y
icacls file_name /grant administrators:F

For Directories :
takeown /f directory_name /r /d y
icacls directory_name /grant administrators:F /t

Note you are the administrator or a part of administrator group to run the command.
via BlogsDNA