I want to clone a list in Sharepoint. This is the code:
private static void CloneList(SPList sourceList, string targetListName)
{
SPWeb web = sourceList.ParentWeb;
web.AllowUnsafeUpdates = true;
Guid targetListId;
targetListId = web.Lists.Add(targetListName, sourceList.Description, sourceList.BaseTemplate);
// irrelevant stuff
}
On the last code line (Lists.Add()) I get the error
operation is not valid due to the current state of the object sharepoint 2010
any idea what to do to solve that issue? (running the code with elevatedPrivilegues does not solve the issue)
Try this…
Greats Hechler