A simple scenario:
I want to delete a pagelayout that is out-dated from our MOSS publishing site. An ex-colleague has created a new page using this page layout and he has not checked it in. I can't delete the pagelayout because his file is referencing it. I can't 'see' the file because it hasn't been checked in, to remove it.
I've tried SPFolder.Items, SPList.GetItemById(), couple of other object model methods. But SharePoint simply won't show that item to me. I've even poked around SPList.GetItem(new SPQuery() { IncludeAllUserPermissions = true; })
Anyone know how to get rid of this item? :-)
Abs's answer lead us gave us the hint - hey how does the ManageCheckedOutFiles page see the files not yet checked-in by other users?
so back in our code
SPDocumentLibrary doclib = PublishingWeb.PagesList as SPDocumentLibrary;
foreach(var checkedoutfile in doclib.CheckedOutFiles)
{
checkedoutfile.TakeOverCheckOut();
var file = doclib.GetItemById(checkedoutfile.ListItemId);
file.CheckIn();
}
Thanks everyone :-)