May 15th, 2009 | No Comments

Below is an example on how to write to the SharePoint log files (located in C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\LOGS folder).

catch(Exception e)
{
Microsoft.Office.Server.Diagnostics.PortalLog.LogString(“Exception: {0} – {1}”, e.Message, e.StackTrace);
}

Written by Ajay Matharu

May 15th, 2009 at 12:21 pm

May 14th, 2009 | No Comments

Following is the simple code to change the value of the appSettings key,

private void UpdateConfig(string strKey, string strValue)
{
Configuration objConfig = WebConfigurationManager.OpenWebConfiguration(”~”);
AppSettingsSection objAppsettings = (AppSettingsSection)objConfig.GetSection(”appSettings”);
if (objAppsettings != null)
{
objAppsettings.Settings[strKey].Value = strValue;
objConfig.Save();
}
}

Written by Ajay Matharu

May 14th, 2009 at 10:32 am