Thursday, July 6, 2017

Disabling ParserEnabled affect: SharePoint 2013

Disabling ParserEnabled affect:
  1. We can't search in document library using Office document properties.
  2. When you upload image file. Thumbnail will not be generated.
  3. When you save a list template, You will not see it in list template gallery.
If you need to disable this property you need to take care of its effect. Disable it only in special sites. if you want it when you upload document using code disable it temporary using code like below:

using (var site = new SPSite("http://sharepoint-portal"))
{
    using (var web = site.OpenWeb())
    {
       SPFile file = web.GetFolder("Documents").Files["mydoc.docx"]; 
       using (var fs = new FileInfo(@"C:\Documents\mydoc.docx").OpenRead())
 
       {
        documentBytes = ..... // get the documents bytes
       }
       web.ParserEnabled = false;
       web.Update();
       file.SaveBinary(documentBytes);
       web.ParserEnabled = true;  
       web.Update();
    }
}

No comments:

Post a Comment