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??
@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.
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 http://msdn.microsoft.com/en-us/library/dd587315(v=office.11).aspx
this talks about the types of events handlers and recivers http://sharepointlogics.com/2008/12/event-handlers-and-event-receivers-in.html
this person is making an event handler for document library http://johanolivier.blogspot.co.uk/2009/12/sharepoint-simple-event-handler.html
In depth on Event Handler Feature http://www.codeproject.com/Articles/17989/Extending-SharePoint-Server-2007-by-using-Features
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 :)
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: http://sharepointnadeem.blogspot.in/2011/12/prevent-duplicate-files-to-be-uploaded.html