SPFile.ScheduleEnd 方法

设置在其的文件将被删除从公共文档库的视图的日期。

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Sub ScheduleEnd ( _
    endDate As DateTime _
)
用法
Dim instance As SPFile
Dim endDate As DateTime

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

参数

  • endDate
    类型:System.DateTime

    DateTime值,该值指定文件应发布 (从公共视图中删除)。

异常

异常 条件
UnauthorizedAccessException

当前用户没有SPBasePermissions.ApproveItems权限。

SPException

文档库EnableModeration属性的值是false。

SPException

文档库EnableMinorVersions属性的值是false。

备注

此方法安排的日期和时间时该文件会从公共视图。

要确保内容永不过期,请通过MaxValue ,作为endDate参数的值。

示例

本示例从当前日期将文件的到期日期设置为指定天数。

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 类

SPFile 成员

Microsoft.SharePoint 命名空间

ScheduleStart

UnPublish

SPFileLevel