SPFile.Recycle Method

Sends the file to the recycle bin.

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

Syntax

'Declaration
<ClientCallableMethodAttribute(RemoveThisObjectFromParentCollection := True)> _
<ClientCallableExceptionConstraintAttribute(FixedId := "3", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "There is an exclusive lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "4", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "There is a shared lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "filenotfound", Condition := "File cannot be found.",  _
    ErrorType := GetType(FileNotFoundException))> _
<ClientCallableExceptionConstraintAttribute(FixedId := "2", ErrorType := GetType(SPFileCheckOutException),  _
    ErrorCode := , Condition := "File is checked out to somebody else")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "1", Condition := "Lack of permissions to perform the operation.",  _
    ErrorType := GetType(UnauthorizedAccessException))> _
Public Function Recycle As Guid
'Usage
Dim instance As SPFile
Dim returnValue As Guid

returnValue = instance.Recycle()
[ClientCallableMethodAttribute(RemoveThisObjectFromParentCollection = true)]
[ClientCallableExceptionConstraintAttribute(FixedId = "3", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "There is an exclusive lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "4", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "There is a shared lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "filenotfound", Condition = "File cannot be found.", 
    ErrorType = typeof(FileNotFoundException))]
[ClientCallableExceptionConstraintAttribute(FixedId = "2", ErrorType = typeof(SPFileCheckOutException), 
    ErrorCode = , Condition = "File is checked out to somebody else")]
[ClientCallableExceptionConstraintAttribute(FixedId = "1", Condition = "Lack of permissions to perform the operation.", 
    ErrorType = typeof(UnauthorizedAccessException))]
public Guid Recycle()

Return Value

Type: System.Guid
A System.Guid object that identifies the file.

See Also

Reference

SPFile Class

SPFile Members

Microsoft.SharePoint Namespace

RevertContentStream

SPRecycleBinType