I've been trying to add a watermark to files as they are uploaded to SharePoint. I tried using several events: ItemAdding, ItemUpdating, ItemCheckedIn.

In ItemUpdating and ItemCheckedIn the file is already in the DB. so I can add a watermark - but it's just a waste of DB read/write (The whole file is written, then I read it, then I re-save it to the db).

the ItemAdding event looks good, it does rise before the content is saved to the DB, but I do not have the content itself (SPItemEventProperties doesn't have any "content" attribute or something similar)

3 Answers 3


You can access the content from the ItemAdding event by using Request.Files property of the context. Try something like this :

HttpFileCollection files = HttpContext.Current.Request.Files;  
    foreach (String key in files.Keys)   
        if (collection[key].ContentLength > 0)   
           Stream stream = files[key].InputStream;  
           string filePath = files[key].FileName;  

For more info, read this post.


Have you tried the ItemAdded event instead? This fires after the item has finished being added to the library.

  • The real questions is - where do I get the content from in the ItemAdded event. Let's say I'm uploading a file to a document library, in the ItemAdded event, where can I see its content to add the water mark?
    – Roy Reznik
    Jul 26, 2012 at 12:49
  • You should be able to get everything you need from properties.ListItem.File (msdn.microsoft.com/en-us/library/…)
    – Dave Wise
    Jul 26, 2012 at 13:31
  • Checked it out - it's just like ItemCheckingIn and ItemUpdating - the file is already in the DB at this point, which means I'm doing extra read & rewrite for every file. that's a huge performance hit.
    – Roy Reznik
    Jul 26, 2012 at 13:59

You can achieve this task during ItemAdded Event. You juts need to set


in Element.xml file of Event receiver.

<Receivers  ListUrl="Lists\Doc">      
  • Could you elaborate a little more on how to access the content of the file during this event, just to have a complete answer? Thanks.
    – Norbert
    Aug 23, 2013 at 7:01
  • Basically, After File Upload in SharePoint Document Library, you find hard to trap the ItemAdded Event. Then you need to use <Synchronization>Synchronous</Synchronization> trapping the file upload. At this time, The file is already uploaded in document library but you can set properties, or retrieve file. Aug 23, 2013 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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