Export (0) Print
Expand All

SPFile.Delete Method

Deletes the file object.

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

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

ExceptionCondition
SPException

An error occurred while deleting the file.

If the file does not exist, the Delete method silently fails and does not throw an exception.

Show:
© 2014 Microsoft