次の方法で共有


SPFile.CheckOut method

Checks the file out of a document library.

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

Syntax

'Declaration
Public Sub CheckOut
'Usage
Dim instance As SPFile

instance.CheckOut()
public void CheckOut()

Exceptions

Exception Condition
SPException

An error occurred when checking out the file.

Remarks

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

Examples

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

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
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();

Note

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.

See also

Reference

SPFile class

SPFile members

CheckOut overload

Microsoft.SharePoint namespace