ItemAdding event – is the list item a file or a folder?

In event receivers other than ItemAdding it is a simple task to determine if the current item is a file or a folder. You would write something along the lines of:

Could not embed GitHub Gist 929b73418983e5a096a6: API rate limit exceeded for 13.250.221.184. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

However in the ItemAdding event properties.ListItem is null. This is because the list item is yet to be created. In order to determine if the current item is a file, you should instead try this:

Could not embed GitHub Gist 956840af62ce94890777: API rate limit exceeded for 13.250.221.184. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)

You are welcome!

Published by

Paul Ryan

As a developer my professional interests are technical and tend to be SharePoint focused. I've been working with SharePoint since 2009 and hope my posts will give back a little to the community that's supported me over this time. I'm also a keen runner (half-marathon) and passionate Brompton bicycle owner.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.