Config file for SharePoint custom timer jobs

SharePoint timer jobs run under the OWSTIMER.exe process.
This process has a configuration file associated with it. We can use this config file to specify the configuration settings that are to be used in custom timer jobs.

Open the OWSTIMER.EXE.CONFIG and add the <appSettings> tag to it.
Then add your key value pairs under this appSettings tag


For this you have to add a reference to System.Configuration
Then you can use the System.Configuration.ConfigurationManager.AppSettings[key] to retrieve the values for a key from the config file.

Example: string dept = System.Configuration.ConfigurationManager.AppSettings["Department"];

Comments

Post a Comment

Popular posts from this blog

Create web part pages with custom layouts in SharePoint 2010

Create a Custom Timer Job in SharePoint 2010

SharePoint list forms display HTML instead of rendering