Saturday, September 22, 2012

Cannot delete file - Access denied

I was over at a friend's place and he told me of a problem he was facing under Windows XP; he had a few files he wanted to delete, .avi and .mp4 video files, and every time he tried, he got an error message saying that access was denied. The error message also said the disk may be write-protected or the file may be in use by a program.

Of course, I searched the internet for solutions. I found several (maybe a few thousand) people who had encountered the problem but couldn't find the solution. I also found several blogs that offered solutions in terms of starting in safe mode, changing owners of the files, etc., but in this particular case the solutions either didn't work or couldn't be implemented because the options mentioned in the context menus mentioned in the solutions simply didn't show up.

After a bit of experimentation I found a technique that worked:

  1. Rename each file and change the extension to .bak: To do this, open the folder containing the files you want to delete, right-click each file and select Rename, then change the .avi or .mp4 to .bak and hit Enter. If you don't see .avi or .mp4 in the file name, it's likely that your folder options are set to "hide known file extensions". You'll need to first change this option. To do this, follow the procedure given here. Then come back here and change the extensions as stated in this step.
  2. When you hit Enter you'll get a warning saying that you might not be able to open this file if you change the extension. Click OK. You don't intend to use the file anyway, you're trying to DELETE it!
  3. Once all files you want to delete are renamed with a .bak extension (you don't HAVE to rename the extensions to .bak, you can rename them to .old or anything you want, as long as you use only letters of the alphabet; .isofedupofthis works as well as .bak), reboot your computer.
  4. When your computer restarts and you get back to your Desktop, navigate to the folder that contains the files you want to delete, select them and delete. Easy-peasy!
Do let me know if this technique doesn't work for you.