I’ve been dealing with a number of item event receivers in SharePoint and I ran across the need to figure out whether or not the binary file associated with an item in a document library is being updated during the ItemUpdating event. I knew there were some additional events in the SPItemEventReceiver class, but it turns out that none of them alert you as to when a binary file is actually being updated.
With the simple option out, I had to turn to a more investigative approach. So I threw in some code to write out the BeforeProperties and AfterProperties of the properties parameter passed into the ItemUpdating method to see if there was some telltale sign of a binary file update, and there were a few.
So if you want to tell whether or not the binary file has been updated in the ItemUpdating method, you just have to check if vti_docstoreversion has a null value in the AfterProperties collection. If it has a value, then the binary file has NOT been updated.
There are some additional properties for which this appears to hold true as well:
- vti_docstoreversion
 - vti_docstoretype
 - vti_metainfoversion
 - vti_contentversionisdirty
 - vti_contenttag
 - vti_modifiedby
 - vti_timelastmodified
 
I’m not sure if they all always hold true, but they appeared to be consistent in what little testing I did.
        
Load comments