Access sitecore settings programmatically (Sitecore 6)
Asked Answered
H

2

21

Is there a way to get to sitecore settings through code.

The specific setting I'm interested in is the data Folder path.

Humblebee answered 8/3, 2010 at 9:36 Comment(0)
K
27

Yes. Look at the Sitecore.Configuration.Settings class (which is your entry point to the Sitecore settings), and use the static DataFolder property:

string dataFolder = Sitecore.Configuration.Settings.DataFolder;
Knorr answered 8/3, 2010 at 9:47 Comment(0)
P
31

If you'd like to get other settings, you may want to try:-

Sitecore.Configuration.Settings.GetSetting("SettingName");

This will work for all sitecore settings, even your custom settings that can be added through the config files in the App_config/Include.

Plenum answered 4/10, 2012 at 4:29 Comment(3)
I enjoy that this is not the correct answer to this problem, but because of the ambiguity of the question, many people who needed this answer (myself included) end up here. +1Broadtail
hi @sean i'm i'm trying to get setting in same manner as you described, it giving me an error when i'm evaluating result.Adorne
@Amitavin what's the error you're getting? This should work if you have a Sitecore setting in your webconfig (or App_Config/Include configs). Make sure it's a Sitecore setting and you can see it when you access the /sitecore/admin/showconfig.aspx page).Plenum
K
27

Yes. Look at the Sitecore.Configuration.Settings class (which is your entry point to the Sitecore settings), and use the static DataFolder property:

string dataFolder = Sitecore.Configuration.Settings.DataFolder;
Knorr answered 8/3, 2010 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.