Tags

Here is the code you can run to unhide the fields:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Reflection;

namespace FixModifiedConsole
{
    class Program
    {
        static void Main(string[] args)
     {
       //Console.WriteLine("program started");
         using (SPSite oSPsite = new SPSite("http://site/teams/ismgmt"))
          {
              using (SPWeb oSPWeb = oSPsite.OpenWeb())
            {
                SPList list = oSPWeb.Lists["Document Library"];
              //foreach (SPField fld in list.Fields)
               //{
                //  Console.WriteLine(fld.Title + " _" + fld.InternalName + "_" + fld.Hidden);
                //} 
                 UnhideSPField(list, "Created");
                 UnhideSPField(list, "Modified");
             }
         }
       Console.WriteLine("program ended");
       Console.ReadLine();
      }
        private static void UnhideSPField(SPList list, string field)
        {
            SPField spfield = list.Fields.GetFieldByInternalName(field);
            Type type = spfield.GetType();
            MethodInfo mi = type.GetMethod("SetFieldBoolValue", BindingFlags.NonPublic | BindingFlags.Instance);
            mi.Invoke(spfield, new object[] { "CanToggleHidden", true });
            spfield.Hidden = false;
            spfield.Update();
        }

    }
}

Advertisements