Export (0) Print
Expand All

SPFile.CheckOut method

Checks the file out of a document library.

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

public void CheckOut()

ExceptionCondition
SPException

An error occurred when checking out the file.

This method calls CheckOut(SPFile.SPCheckOutType, String) with Online and null .

The following code example shows how to check out all the files in the Shared Documents folder for a specified subsite.

SPSite oSiteCollection = SPContext.Current.Site;
SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name/Subsite_Name"];
SPFolder oFolder = oWebsite.Folders["Shared Documents"];
SPFileCollection collFiles = oFolder.Files;

for (int intIndex=0; intIndex<collFiles.Count; intIndex++)
{
    collFiles[intIndex].CheckOut();
}
oWebsite.Dispose();
NoteNote

Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects.

Show:
© 2014 Microsoft