mercoledì 20 marzo 2013

C# - Getting Value From App.Config



public string GetValueFromConfig(string chiave)
{
            ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap();
            fileMap.ExeConfigFilename = @"YourAppFile.exe.config";

Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);

            AppSettingsSection app = config.AppSettings;
            return app.Settings[chiave].Value;
        }

Nessun commento:

Posta un commento