Partager via


ContentSource.Delete, méthode (Microsoft.Office.Server.Search.Administration)

Deletes the content source.

Espace de noms : Microsoft.Office.Server.Search.Administration
Assembly : Microsoft.Office.Server.Search (dans microsoft.office.server.search.dll)

Syntaxe

'Déclaration
Public Sub Delete
'Utilisation
Dim instance As ContentSource

instance.Delete
public void Delete ()

Exemple

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 Procédure : supprimer une source de contenu.

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());
            }
        }
    }
}

Voir aussi

Référence

ContentSource, classe
Membres ContentSource
Microsoft.Office.Server.Search.Administration, espace de noms
Content, classe

Autres ressources

Mise en route avec le modèle objet Administration de recherche de contenu d'entreprise
Vue d'ensemble des sources de contenu
Gestion du contenu
Procédure : récupérer les sources de contenus pour un fournisseur de services partagés
Procédure : ajouter une source de contenu
Procédure : supprimer une source de contenu
Procédure : gérer l'analyse d'une source de contenu par programme
Procédure : configurer par programme une planification d'analyse pour une source de contenu