0
votes

This is my code:

if (docLib.DoesUserHavePermissions(SPBasePermissions.DeleteVersions))
{
     item.File.CheckIn(comment, SPCheckinType.OverwriteCheckIn);
}
else
{
     item.File.CheckIn(comment);
}

I have versioning enabled for a document library. Let's say I have User Bobby, he does not have delete versions permissions and when he wants to upload and check in the document, there will be two versions of that document.

The issue is that Bobby does not have delete versions permissions, so using OverwriteCheckIn will throw an Access Denied error.

Anyone has any solution?

1

1 Answers

0
votes

I think you have to first check out that file and then add it in to the document library and after that may be you can overwrite the existing file . OR you can run this code inside RunWithElevatedPrivileges