Click to Rate and Give Feedback
MSDN
MSDN Library
Web Development
SDK Documentation
SPFile Class
SPFile Methods
CheckOut Method
 CheckOut Method ()
Community Content
In this section
Statistics Annotations (0)
Collapse All/Expand All Collapse All
This page is specific to
The 2007 product release

Other versions are also available for the following:
SPFile.CheckOut Method () (Microsoft.SharePoint)
Checks the file out of a document library.

Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in microsoft.sharepoint.dll)
Visual Basic (Declaration)
Public Sub CheckOut
Visual Basic (Usage)
Dim instance As SPFile

instance.CheckOut
C#
public void CheckOut ()

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

Visual Basic
Dim site As SPSite = SPContext.Current.Site
Dim targetWeb As SPWeb = site.AllWebs("Site_Name/Subsite_Name")
Dim docLibFolder As SPFolder = targetWeb.Folders("Shared Documents")
Dim docLibFiles As SPFileCollection = docLibFolder.Files
Dim i As Integer

For i = 0 To docLibFiles.Count - 1

    docLibFiles(i).CheckOut()

Next i
C#
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 Best Practices: Using Disposable Windows SharePoint Services Objects.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker