Partilhar via


SPRecycleBinItem.Restore Method

Restores the item to its original location.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "1", Condition := "Item does not exist. It may have been restored or deleted by another user.",  _
    ErrorType := GetType(ArgumentException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "4", ErrorCode := , Condition := "A file or folder with the same name already exists",  _
    ErrorType := GetType(SPException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "3", ErrorCode := , Condition := "1)Duplicate values for the file were found for the columns in the list 
2)Duplicate values for the folder were found for the columns in the list 
3)Duplicate values for the listitem were found for the columns in the list 
4)The restore of one of the Recycle Bin items in the batch failed because of above.",  _
    ErrorType := GetType(SPException))> _
<ClientCallableMethodAttribute(RemoveThisObjectFromParentCollection := True)> _
<ClientCallableExceptionConstraintAttribute(FixedId := "accessdenied", Condition := "Lack of permissions to perform the operation.",  _
    ErrorType := GetType(UnauthorizedAccessException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "6", ErrorCode := , Condition := "1)The original list or list item or document containing the Recycle Bin item was not restored 
2)The restore of one of the Recycle Bin items in the batch failed because of above.",  _
    ErrorType := GetType(SPException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "5", ErrorCode := , Condition := "1)Invalid lookup values were found for the columns in the list 
2)The restore of one of the Recycle Bin items in the batch failed because of above.",  _
    ErrorType := GetType(SPException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "thresholdexceeded", ErrorCode := , Condition := "Operation exceeds the list view threshold enforced by the administrator.",  _
    ErrorType := GetType(SPQueryThrottledException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "2", ErrorCode := , Condition := "A List with the same name already exists",  _
    ErrorType := GetType(SPException))> _
Public Sub Restore
'Usage
Dim instance As SPRecycleBinItem

instance.Restore()
[ClientCallableExceptionConstraintAttribute(FixedId = "1", Condition = "Item does not exist. It may have been restored or deleted by another user.", 
    ErrorType = typeof(ArgumentException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "4", ErrorCode = , Condition = "A file or folder with the same name already exists", 
    ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "3", ErrorCode = , Condition = "1)Duplicate values for the file were found for the columns in the list 
2)Duplicate values for the folder were found for the columns in the list 
3)Duplicate values for the listitem were found for the columns in the list 
4)The restore of one of the Recycle Bin items in the batch failed because of above.", 
    ErrorType = typeof(SPException))]
[ClientCallableMethodAttribute(RemoveThisObjectFromParentCollection = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "accessdenied", Condition = "Lack of permissions to perform the operation.", 
    ErrorType = typeof(UnauthorizedAccessException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "6", ErrorCode = , Condition = "1)The original list or list item or document containing the Recycle Bin item was not restored 
2)The restore of one of the Recycle Bin items in the batch failed because of above.", 
    ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "5", ErrorCode = , Condition = "1)Invalid lookup values were found for the columns in the list 
2)The restore of one of the Recycle Bin items in the batch failed because of above.", 
    ErrorType = typeof(SPException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "thresholdexceeded", ErrorCode = , Condition = "Operation exceeds the list view threshold enforced by the administrator.", 
    ErrorType = typeof(SPQueryThrottledException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "2", ErrorCode = , Condition = "A List with the same name already exists", 
    ErrorType = typeof(SPException))]
public void Restore()

Exceptions

Exception Condition
SPQueryThrottledException

The operation exceeds the list view threshold set by an administrator.

SPException

An exception occurred while restoring the item.

See Also

Reference

SPRecycleBinItem Class

SPRecycleBinItem Members

Microsoft.SharePoint Namespace