SPDocumentLibrary.CheckedOutFiles property

Gets the collection of files that are uploaded to the document library but are not checked in.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public ReadOnly Property CheckedOutFiles As IList(Of SPCheckedOutFile)
    Get
'Usage
Dim instance As SPDocumentLibrary
Dim value As IList(Of SPCheckedOutFile)

value = instance.CheckedOutFiles
public IList<SPCheckedOutFile> CheckedOutFiles { get; }

Property value

Type: System.Collections.Generic.IList<SPCheckedOutFile>
An IList<T> object that contains SPCheckedOutFile objects with information about files that have been uploaded but not checked in.

Remarks

When someone creates a new file or adds a new file to a library that requires check-out, the file is initially checked out. The person who creates or adds the file must check it in before other people can use it. The CheckedOutFiles property returns a collection of SPCheckedOutFile objects with information about files that have been added to the library but have not been checked in.

Examples

The following example is a console application that opens the root Web site, finds all document libraries that require documents to be checked out before they can be modified, and prints a report with information about any document that was uploaded but not checked in.

Imports System
Imports System.Collections.Generic
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using site As SPSite = New SPSite("http://localhost")
         Using web As SPWeb = site.OpenWeb()

            Console.WriteLine("Documents Uploaded But Not Checked In")
            Console.WriteLine(vbCrLf + "{0,-20} {1,-25} {2}", "Library", "File", "Uploaded by")
            Console.WriteLine(New String("-"c, 70))

            For Each list As SPList In web.Lists

               ' If users are required to check out documents...
               If list.ForceCheckout Then
                  Dim library As SPDocumentLibrary = CType(list, SPDocumentLibrary)

                  ' ...print information about files uploaded but not checked in.
                  Dim files As IList(Of SPCheckedOutFile) = library.CheckedOutFiles
                  For Each file As SPCheckedOutFile In files
                     Console.WriteLine("{0,-20} {1,-25} {2}", _
                         file.DirName, file.LeafName, file.CheckedOutBy)
                  Next
               End If
            Next

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub
End Module
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite site = new SPSite("http://localhost"))
         {
            using (SPWeb web = site.OpenWeb())
            {
               Console.WriteLine("Documents Uploaded But Not Checked In");
               Console.WriteLine("\n{0,-20} {1,-25} {2}", "Library", "File", "Uploaded by");
               Console.WriteLine(new string('-', 70));

               foreach (SPList list in web.Lists)
               {
                  // If users are required to check out documents...
                  if (list.ForceCheckout)
                  {
                     SPDocumentLibrary library = (SPDocumentLibrary)list;

                     // ...print information about files uploaded but not checked in.
                     IList<SPCheckedOutFile> files = library.CheckedOutFiles;
                     foreach (SPCheckedOutFile file in files)
                     {
                        Console.WriteLine("{0,-20} {1,-25} {2}", 
                            file.DirName, file.LeafName, file.CheckedOutBy);
                     }
                  }
               }
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

See also

Reference

SPDocumentLibrary class

SPDocumentLibrary members

Microsoft.SharePoint namespace

ForceCheckout