SPFile.CheckIn method (String)
檢查指定的註解的文件庫檔案中。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Sub CheckIn ( _
comment As String _
)
'用途
Dim instance As SPFile
Dim comment As String
instance.CheckIn(comment)
public void CheckIn(
string comment
)
參數
comment
Type: System.String字串,包含有關簽入註解。
Exceptions
Exception | Condition |
---|---|
SPException | 簽入檔案時,就會發生錯誤。 |
備註
這個方法會呼叫與第二個引數設定為MinorCheckIn的CheckIn(String, SPCheckinType) 。
雖然在簽入註解並不需要在 UI 中, CheckIn方法會需要註解,它可以是空字串,做為參數。
如果已啟用版本控制的檔案所屬的文件庫, CheckIn方法會建立SPFileVersion物件。
Examples
下列程式碼範例會檢查指定的使用者是否簽出的對象,子網站的共享文件文件庫回檔案。
Dim site As SPSite = SPContext.Current.Site
Dim web As SPWeb = site.AllWebs("Site_Name/Subsite_Name")
Dim docLibFolder As SPFolder = web.Folders("Shared Documents")
Dim docLibFiles As SPFileCollection = docLibFolder.Files
Dim i As Integer
For i = 0 To docLibFiles.Count - 1
If docLibFiles(i).CheckedOutBy.LoginName = "User_Name" Then
docLibFiles(i).CheckIn("Checkin_Comment")
End If
Next i
SPSite oSiteCollection = SPContext.Current.Site;
using(SPWeb oWebsite = oSiteCollection.AllWebs["Site_Name/Subsite_Name"])
{
SPFolder oFolder = oWebsite.Folders["Shared Documents"];
SPFileCollection collFiles = oFolder.Files;
for (int intIndex=0; intIndex<oFolder.Count; intIndex++)
{
if (oFolder[intIndex].CheckedOutBy.LoginName == "User_Name")
{
oFolder[intIndex].CheckIn("Checkin_Comment");
}
}
}
![]() |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |