共用方式為


SPFile.ScheduleEnd method

設定將從公用檢視的文件庫移除所在檔案的日期。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public Sub ScheduleEnd ( _
    endDate As DateTime _
)
'用途
Dim instance As SPFile
Dim endDate As DateTime

instance.ScheduleEnd(endDate)
public void ScheduleEnd(
    DateTime endDate
)

參數

  • endDate
    Type: System.DateTime

    DateTime值,指定何時應該未發行的檔案 (從公用檢視中移除)。

Exceptions

Exception Condition
UnauthorizedAccessException

目前的使用者沒有SPBasePermissions.ApproveItems權限。

SPException

文件庫的EnableModeration屬性的值是false。

SPException

文件庫的EnableMinorVersions屬性的值是false。

備註

這個方法會預定的日期和時間何時從公用檢視中移除檔案。

若要確保內容永遠不會到期,傳遞MaxValue做為endDate參數的值。

Examples

本範例將指定的天數的檔案到期日設定從目前的日期。

public void Retire(SPFile file, double days)
{
    // Set an expiration date only after content has been published.
    if ((file != null) && (file.Level == SPFileLevel.Published))
    {
        try
        {
            file.ScheduleEnd(DateTime.Now.AddDays(days));
        }
        catch (SPException ex)
        {
            // error handling
        }
    }
    else
    {
        throw new Exception("A file must be published before you can schedule it for retirement.");
    }
}
Public Sub Retire(ByRef file As SPFile, ByVal days As Double)

    'Set an expiration date only after content has been published.
    If (file Is Nothing) And (file.Level = SPFileLevel.Published) Then

        Try

            file.ScheduleEnd(DateTime.Now.AddDays(days))

        Catch ex As SPException

            ' error handling

        End Try

    Else

        Throw New Exception("A file must be published before you can schedule it for retirement.")

    End If

End Sub

請參閱

參照

SPFile class

SPFile members

Microsoft.SharePoint namespace

ScheduleStart

UnPublish

SPFileLevel