ContentSource.Delete 方法 (Microsoft.Office.Server.Search.Administration)
Deletes the content source.
命名空间: Microsoft.Office.Server.Search.Administration
程序集: Microsoft.Office.Server.Search (在 microsoft.office.server.search.dll 中)
语法
声明
Public Sub Delete
用法
Dim instance As ContentSource
instance.Delete
public void Delete ()
示例
The following code example deletes a content source from a Shared Service Provider's collection of content sources. For a complete, step-by-step walkthrough of this sample code, see 如何:删除内容源.
Prerequisites
Ensure a Shared Service Provider is already created.
Project References
Add the following Project References in your console application code project before running this sample:
Microsoft.SharePoint
Microsoft.Office.Server
Microsoft.Office.Server.Search
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;
namespace DeleteContentSourceSample
{
class Program
{
static void Main(string[] args)
{
try
{
//Replace <SiteName> with the name of a site using the Shared Service Provider.
string strURL = "<SiteURL>";
Content sspContent = new Content(SearchContext.GetContext(new SPSite(strURL)));
ContentSourceCollection sspContentSources = sspContent.ContentSources;
//Replace <ContentSourceName> with the ID for the content source to delete.
string strCSName = "<ContentSourceName>";
ContentSource contentSource = sspContentSources[strCSName];
contentSource.Delete();
Console.WriteLine(strCSName + " deleted.");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
另请参阅
参考
ContentSource 类
ContentSource 成员
Microsoft.Office.Server.Search.Administration 命名空间
Content 类
其他资源
企业级搜索管理对象模型入门
内容源概述
管理内容
如何:检索共享服务提供程序的内容源
如何:添加内容源
如何:删除内容源
如何:以编程方式管理对内容源的爬网
如何:以编程方式配置内容源的爬网计划