In my opinion, it's primarily the responsibility of the operating system to prevent undesired deletes.
The most important folders are write-protected by windows 7 for example. Deleting them will fail with an exception. On Unix, you'll have to make sure appropriate file-system permissions are in place and you can't do much harm.
However, we all know a sysadmin who told us the story of his accidental rm -rf / command, issued as root.
As for applications: Make sure the filesystem-permissions are setup reasonably, then you can prevent at least some harm. It's a best practice to run applications with the least privileges necessary.
If your program needs to be run as root, for whatever reason, then throw in some code to check if the location to be deleted is not critical to the system. Or chroot the system for the application.
You could also white-list the directories that are allowed to be deleted and double check everytime, if that makes you feel safe. But memory corruption for example has a chance to break through any validation-routines. If you have temporary data, keep it in a wellknown folder and don't distribute it accross the system.
Edit: Now I've been talking to various co-workers of mine and we inspected our codes and guess what: All of the directories we are deleting are hard-coded constants. There're only a few cases in which files are deleted, mostly by extension or the name they start with. So in most of our cases another layer of validation is simply pointless and a unit test is enough to make sure that the right directory is cleared or deleted.
Now, there might be other cases where paths are combined with environment variables and so on. But when the environment variable is set to the wrong value and you hit by accident a directory which shouldn't have been deleted, who should've kown that but the sysadmin? Clearly, this falls in his responsibility then.
The only edge case I can imagine are deletions by regular expressions. But what good are regular expressions for deletion when you want to validate by white listing file names? Or what good are validations by regular expressions when you're deleting by regular expressions?
The only case in which I'd recommend some sort of whitelisting validation is, when you are blindly concatenating strings to create a directory name. But I'd rather have a decent unit test for it.
And protection against memory corruption: Well, there's little you can do, because you cannot guarantee any behaviour whatsoever when that strikes.