I hate to admit it, but I struggled with this one all day. My event receiver needs to update a field of its parent folder. This little bit shows how to do it:
private void UpdateParentFolder(SPItemEventProperties properties)
SPFolder thisItemFolder = properties.ListItem.File.ParentFolder;
thisItemFolder.Item["ZZ Approval Status"] = "Good news, everyone!";
} // UpdateParentFolder
In this case, I’m working with a document library and the properties are coming from an ItemAdded event.
The trick is that you can’t get the SPFolder of the item directly from the item itself (i.e. properties.ListItem.Folder is null). Instead, go to the list item’s associated File and get the File’s folder.
Subscribe to my blog!