共用方式為


SPFile.UnPublish Method

Removes the file with the specified comment from content approval.

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

Syntax

'Declaration
<ClientCallableExceptionConstraintAttribute(FixedId := "10", ErrorType := GetType(SPDuplicateValuesFoundException),  _
    ErrorCode := , Condition := "The list item could not be updated because duplicate values were found for one or more field(s) in the list")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "8", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "The operation timed out")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "12", ErrorType := GetType(UnauthorizedAccessException),  _
    Condition := "Lack of permission to perform the operation")> _
<ClientCallableAttribute> _
<ClientCallableExceptionConstraintAttribute(FixedId := "4", ErrorType := GetType(SPFileCheckOutException),  _
    ErrorCode := , Condition := "The file is already checked out")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "5", ErrorType := GetType(SPFileCheckOutException),  _
    ErrorCode := , Condition := "The file is not checked out")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "6", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "There is an exclusive lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "7", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "There is a shared lock on the file")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "9", ErrorType := GetType(SPFileLockException),  _
    ErrorCode := , Condition := "The file is not locked")> _
<ClientCallableExceptionConstraintAttribute(FixedId := "11", ErrorType := GetType(SPInvalidLookupValuesException),  _
    ErrorCode := , Condition := "The list item could not be updated because because invalid lookup values were found for one or more field(s) in the list")> _
Public Sub UnPublish ( _
    comment As String _
)
'Usage
Dim instance As SPFile
Dim comment As String

instance.UnPublish(comment)
[ClientCallableExceptionConstraintAttribute(FixedId = "10", ErrorType = typeof(SPDuplicateValuesFoundException), 
    ErrorCode = , Condition = "The list item could not be updated because duplicate values were found for one or more field(s) in the list")]
[ClientCallableExceptionConstraintAttribute(FixedId = "8", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "The operation timed out")]
[ClientCallableExceptionConstraintAttribute(FixedId = "12", ErrorType = typeof(UnauthorizedAccessException), 
    Condition = "Lack of permission to perform the operation")]
[ClientCallableAttribute]
[ClientCallableExceptionConstraintAttribute(FixedId = "4", ErrorType = typeof(SPFileCheckOutException), 
    ErrorCode = , Condition = "The file is already checked out")]
[ClientCallableExceptionConstraintAttribute(FixedId = "5", ErrorType = typeof(SPFileCheckOutException), 
    ErrorCode = , Condition = "The file is not checked out")]
[ClientCallableExceptionConstraintAttribute(FixedId = "6", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "There is an exclusive lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "7", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "There is a shared lock on the file")]
[ClientCallableExceptionConstraintAttribute(FixedId = "9", ErrorType = typeof(SPFileLockException), 
    ErrorCode = , Condition = "The file is not locked")]
[ClientCallableExceptionConstraintAttribute(FixedId = "11", ErrorType = typeof(SPInvalidLookupValuesException), 
    ErrorCode = , Condition = "The list item could not be updated because because invalid lookup values were found for one or more field(s) in the list")]
public void UnPublish(
    string comment
)

Parameters

  • comment
    Type: System.String

    A string that contains the comment.

Exceptions

Exception Condition
SPException

The list item associated with the file is null .

-or-

The SPList in which the list item is located does not support minor versions.

-or-

The value of the CheckOutType is Online.

-or-

The moderated list is an unpublished document, which is not pending or approved.

-or-

The nonmoderated list is an unpublished document, which is not a major version.

-or-

An error occurred when removing the file.

See Also

Reference

SPFile Class

SPFile Members

Microsoft.SharePoint Namespace