Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to retrieve an application setting
Message
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01482778
Message ID:
01482817
Vues:
48
Hi Vov. Thnaks for replying.

Properties.Settings.Default.CSVFile... this worked pefectly.

Regards,
gerard



>The syntax that you're using applies to the pre-defined 'appSettings' section - which is not what you are dealing with here. I don't know if there's a more elegant way of accessing a ClientSettingsSection but something like this will work:
ClientSettingsSection y = (ClientSettingsSection) ConfigurationManager.GetSection("applicationSettings/MYEXE.Properties.Settings");
>string s = y.Settings.Get("CSVFile").Value.ValueXml.InnerText;
>
>UPDATE: If the app.config was created from Settings.Settings then won't this work:
string s = Properties.Settings.Default.CSVFile;
>
>>I am trying to retrieve an application setting but an empty string is being returned on a Windows FormApplication
>>
>> string importFile = System.Configuration.ConfigurationManager.AppSettings["CSVFile"];
>> MessageBox.Show("Import File = " + importFile);
>>
>>My MyApp.Exe_Config is:
>>
>>
>><?xml version="1.0" encoding="utf-8" ?>
>><configuration>
>>    <configSections>
>>        <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
>>            <section name="MYEXE.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
>>        </sectionGroup>
>>    </configSections>
>>    <applicationSettings>
>>        <MYEXE.Properties.Settings>
>>            <setting name="CSVFile" serializeAs="String">
>>                <value>This is a CSV File Setting</value>
>>            </setting>
>>        </MYEXE.Properties.Settings>
>>    </applicationSettings>
>></configuration>
>>
>>
>>Any ideas of what could be wrong.
>>TIA, Gerard
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform