ContentSource.Delete Method
Deletes the content source.
Namespace: Microsoft.Office.Server.Search.Administration
Assembly: Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)
Syntax
'Declaration
Public Sub Delete
'Usage
Dim instance As ContentSource
instance.Delete()
public void Delete()
Examples
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 How to: Delete a Content Source.
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());
}
}
}
}
See Also
Reference
Microsoft.Office.Server.Search.Administration Namespace
Microsoft.Office.Server.Search.Administration.Content
Other Resources
Getting Started with the Enterprise Search Administration Object Model
How to: Retrieve the Content Sources for a Shared Services Provider
How to: Delete a Content Source
How to: Programmatically Manage the Crawl of a Content Source
How to: Programmatically Configure a Crawl Schedule for a Content Source