ARTICLE

How to add a file type to the content index in SharePoint 2010

Posted by Vijai Anand Articles | SharePoint 2010 February 07, 2011
In this article we will be seeing how to add a file type to the content index in SharePoint 2010.
Reader Level:

In this article we will be seeing how to add a file type to the content index in SharePoint 2010.

Using Central Administration:

  • Go to Central Administration => Application Management => Manage Service Applications => Search Service Application.
  • In the navigation, go to Crawling => File Types.
  • Click on "New File Type".

    Share1.gif
     
  • Enter the file extension.

    Share2.gif
     
  • Click on Ok.
  • A new file type is added successfully.

Using Visual Studio 2010:

  • Open Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application from the installed templates.
  • Enter the Name and click Ok.
  • Add the following references.

    o Microsoft.SharePoint.dll
    o Microsoft.Office.Server.dll
    o Microsoft.Office.Server.Search.dll
     
  • Add the following namespaces.

    o using Microsoft.Office.Server.Search.Administration;
    o using Microsoft.Office.Server;
    o using Microsoft.SharePoint;
     
  • Replace the code with the following.

                     //  search service application name             
                string ssaName ="Search Service Application";
                SearchContext context =SearchContext.GetContext(ssaName);
                Content ssaContent =new Content(context);
                //ExtensionList => Get the list of file name extensions
                ssaContent.ExtensionList.Create("ascx");

     
  • Build the solution.
  • Hit F5.
  • A new file type is added successfully.

    Share3.gif

Using Powershell:

  • Run SharePoint 2010 Management Shell as an administrator.
  • Add the following script to create a new file type to the content index.

    $ssaName="Search Service Application"
    $context=[Microsoft.Office.Server.Search.Administration.SearchContext]::GetContext($ssaName)
    $ssaContent=New-Object Microsoft.Office.Server.Search.Administration.Content($context)
    $ssaContent.ExtensionList.Create("ascx")

    Share4.gif
     

Login to add your contents and source code to this article
post comment
     
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Join a Chapter
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Get Career Advice from Experts