Posts Tagged ‘C#’

Differentiating File/Folder in SharePoint Eventreceiver


You can hook SharePoint eventreceivers to lists and libraries to execute custom code whenever a new document is being uploaded to a document library. The ‘ItemAdding’ event fires when a user adds a new document to a library, but also whenever a new folder is created. However, due to the vast variety of ways to upload a document (one document, multi-document, WebDAV, Office, WebService, etc.), the event always seems to behave a little different.

Having a reliable way to check whether the user added a new document or created a new folder in a document library is key for a solid eventreceiver.