SPFile.UndoCheckOut 方法
撤消文件的签出。
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Sub UndoCheckOut
用法
Dim instance As SPFile
instance.UndoCheckOut()
public void UndoCheckOut()
异常
异常 | 条件 |
---|---|
SPException | 撤消文件的签出时发生错误。 |
备注
此方法将恢复现有在线或离线的签出当前文件。
示例
下面的代码示例撤消共享文档文档库的子网站中的文件的签出,如果指定的用户是人检出。
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。