I have a document library which has 18000 items. When I go to the All Site Contents page, I see 18000 items against the document library name.

But when I query the items in C# as

foreach(SPListItem item in list.Items)

I get a count of just 17000 items

Is it possible that the remaining items are checked-out and thus are not coming in the query(I am an SCA though).

What could be the reason

  • How are you querying the count? May 19, 2015 at 10:00
  • 1
    Show me the whole code... May 19, 2015 at 10:30

1 Answer 1


We can get the Checked out files using the below code. No matter what you try, you cannot get the checked out files by querying the document library as these are saved in a separate table in the database.

SPDocumentLibrary library = (SPDocumentLibrary)list;
IList<SPCheckedOutFile> files = library.CheckedOutFiles;
foreach (SPCheckedOutFile file in files)

The count difference was due to the fact that those 1000 items were never checked-in and can be accessed through the above code.

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.