I have a task to restore Document Set to its latest snapshot. Since this functionality is implemented in event receiver, I use Server Side Object Model. By now, I have managed to restore the DS properties by updatingDS item, delete all document (file) versions higher that ones used in DS using SPFile.Versions.DeleteByID(id), but can not delete latest Document item versions. When I run

    foreach(SPListItemVersion itemVer in file.Item.Versions)
        if(double.Parse(itemVer.VersionLabel)> versionUsed) itemVer.Delete();

I get Microsoft.SharePoint.SPException: 'Cannot delete the current version'. I even saw an article that says you cannot delete current item version, so, you should restore previous version and then you would be able to delete it. But I managed to delete the file's version, but not item's. As far as I can see, this item version now has null value in FileVersion. Any idea on how to delete this item's version?

1 Answer 1


That is the expected behavior. The latest version of the item is nothing but the item itself. System will not allow you to delete the latest version of the item. It's like you are deleting the item itself. So if you want to delete the latest version of the item, delete the item itself.


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.