Tutorial :SharePoint: Can I see the content of a document in the ItemAdding() event handler?


I'd like to inspect the content of a file before it is uploaded to the SharePoint doc library.
I hooked up a handler to the ItemAdding() event but don't know how to get the content of the file.
Note: I know that in the ItemAdded() I can use properties.ListItem.File but that's too late.

Thanks in advance.


Yes, the file has not been created at this point.

Try using the properties.AfterProperties or properties.BeforeProperties.

Edit: It is only after the file has been added that the lists properties are created. SharePoint will add the defaults for the list metadata to the file (Office 2007 only) once the item has been created, but before the ItemAdded event. Bugger.


No you can't.
During ItemAdding, you have access to document/item properties as Nat said, but you don't have access to file content.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »