SPFile.UndoCheckOut method
復原取出檔案。
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Sub UndoCheckOut
'用途
Dim instance As SPFile
instance.UndoCheckOut()
public void UndoCheckOut()
Exceptions
Exception | Condition |
---|---|
SPException | 復原取出檔案時發生錯誤。 |
備註
這個方法會還原目前檔案的現有連線或離線簽出。
Examples
如果指定的使用者是簽出,下列程式碼範例會復原子網站的共享文件文件庫中的檔案簽出。
Dim siteCollection As SPSite = SPContext.Current.Site
Dim site As SPWeb = siteCollection.AllWebs("Site_Name/Subsite_Name")
Dim docLibFolder As SPFolder = site.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 = "Domain_Name\User" Then
docLibFiles(i).UndoCheckOut()
End If
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++)
{
if (collFiles[intIndex].CheckedOutBy.LoginName == "Domain_Name\\User")
{
collFiles[intIndex].UndoCheckOut();
}
}
oWebsite.Dispose();
![]() |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |