SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

i want an event handler for document library (itemadding and itemChekingIn) that does not allow to add a file to that document library that already been in there.does anyone can give me hint for this??

share|improve this question

@amin ba...yes we can do this based on which parameter/metedata field you want to check for duplicate item?

you can use CAML query to find if the item with that metadata field and based on no. of results returns you can identify if item already exist or not.

share|improve this answer
also...check the library settings which says "Overwrite if Item exist"...i think setting this to false..would not accept duplicate items – Ketan03 Aug 14 '12 at 8:44

Yes it is possible here are some links, this should help you to get started into the right direction:

Shows you the events for document library event handler

this talks about the types of events handlers and recivers

this person is making an event handler for document library

In depth on Event Handler Feature

with all these you should become a pro ;) . The documentation from msdn alone is gold dust!

EDIT** as ketan has said you can just check if item exists to not add it in ;) but i guess if you want to learn and/or do other functions than the above is more than enough to get you going!

hope this helps :)

share|improve this answer

I had a somewhat similar requirement when I needed to prevent uploading of duplicate files to document library. You may find this link useful to get started:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.