Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

Reading Application Settings using C# VS 2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jim Rand - 11 Jul 2006 23:41 GMT
In Properties / Settings, I've got a setting (say "ExportPath") with a value
(say "C:\\Tmp").

Using C#, how do you get the setting value?

string settingValue = SomeNETWhatever["ExportPath"];
kishor - 12 Jul 2006 07:30 GMT
If you are using visual studio.
add a config file to your solution.
in that file put your entries like this

<configuration>
    <appSettings>
        <add key="ExportPath" value="C:\\Tmp" />       
    </appSettings>
</configuration>

and use this

string Exportpath=
CStr(System.Configuration.ConfigurationSettings.AppSettings("ExportPath"))

Bye
Kishor Pise

> In Properties / Settings, I've got a setting (say "ExportPath") with a value
> (say "C:\\Tmp").
>
> Using C#, how do you get the setting value?
>
> string settingValue = SomeNETWhatever["ExportPath"];
Jim Rand - 12 Jul 2006 17:57 GMT
After much time, I've figured it out how to read the application settings
created in the designer:

Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
ConfigurationSectionGroup configGroup =
config.SectionGroups["applicationSettings"];
ClientSettingsSection settingsSection = (ClientSettingsSection)
configGroup.Sections["AppSettings.Properties.Settings"];
SettingElementCollection elements = settingsSection.Settings;
foreach (SettingElement element in elements)
{
   txtOutput.Text += element.Name + ":" + element.Value.ValueXml.InnerText
+ Environment.NewLine;
}

A simpler approach is just to use the AppSettings that you suggested.

Jim

> If you are using visual studio.
> add a config file to your solution.
[quoted text clipped - 21 lines]
>>
>> string settingValue = SomeNETWhatever["ExportPath"];

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.