Question: Which is better approach and why.

Answer: 
You should seek out the UI guidelines for the platform you are developing on (search for "human interface guidelines" or "look and feel design guidelines"). If they exist, you should follow them so your app is likely to conform to the user's expectations. For example, Apple has [specific guidelines](http://developer.apple.com/mac/library/documentation/userexperience/conceptual/applehiguidelines/XHIGWindows/XHIGWindows.html#//apple_ref/doc/uid/20000961-BACJGAAI) for what to do in this situation on Mac OS X.

The typical advice for this particular scenario is not to have "Yes" or "No" buttons, but buttons that describe the action they perform. For example, you can display a message box like: "Document a.txt has been modified. Save changes?" with the buttons "Save", "Exit without saving", and "Cancel". This makes it clear to the user what each button will do.
I hate being asked if I want to save, personally. If I needed to I probably did. If I've forgotten then most programs I use have an auto-save feature.

The idea about seeking out UI guidelines is good, but I agree with the person who suggested minimal user intervention. His analogy about writing on paper hit the nail on the head. Many programs come with some sort of version control these days.