I have googled a lot for finding a simple method that will give the maximum ID of a SharePoint list/library. But I have found lots of complex codes and those are also large in lines. I was very astonished that it should be a very simple task. Then I have tried it in my way and it was working:
private int GetMaxID()
{
SPList listName = spWeb.Lists["ListName"];
int maxID = 0;
SPListItemCollection listCollection = listName.Items;
foreach (SPListItem item in listCollection)
{
maxID = Convert.ToInt32(item["ID"]);
}
return maxID;
}
It was so simple. Isn't it...........!!