I've defined a Document Library named "Sales" on Sharepoint 2010. And I use the following code fragment to add all names who have checked out a file to a listbox:
lstCheckedOut.Items.Clear();
var docLib = SPContext.Current.Web.Lists["Sales"] as SPDocumentLibrary;
// Code fragment 1
foreach (var doc in docLib.CheckedOutFiles) // No files are checked out ?
{
lstCheckedOut.Items.Add(doc.CheckedOutBy.ToString());
}
// Code fragment 2
foreach (SPItem doc in docLib.Items)
{
string name = doc["Checked Out To"] as string; // Just working fine ?
if (!string.IsNullOrEmpty(name))
{
lstCheckedOut.Items.Add(name);
}
}
Why are no files present in the 'CheckedOutFiles' property ?