Shaitan00 Posted January 31, 2005 Posted January 31, 2005 I am trying to store some information (like application paths) in the web.config file of my ASP C# project. To that end I did the following: WEB.CONFIG SOURCE CODE: ?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <add key="ApplicationDir" Value="C:\Application"/> <add key="DatabaseDir" Value="\Database\"/> <add key="UpdateDir" Value="\UpdatePackages\"/> </appSettings> <system.web> ...(lot of stuff that was generated automatically)... </system.web> </configuration> Note that I manually added the <appSettings> field (it was not automatically there), is it possible I placed it in the wrong part of the web.config file? C# SOURCE CODE: string appDir = ConfigurationSettings.appSettings["ApplicationDir"]; string updDir = ConfigurationSettings.appSettings["UpdateDir"]; string SaveLocation = appDir + updDir + fn; I use this code to create the SavePath for uploaded Update Files. However, on compile, I get the following error: The type or namespace name 'ConfigurationSettings' could not be found (are you missing a using directive or an assembly reference?) Nothing appears in VC# when I type ConfigurationSettings. (should give me a list of choices) Any clues why? Is it because I added it manually and need to add something else to the XML file? Quote
mocella Posted January 31, 2005 Posted January 31, 2005 Try something like this: string appDir = ConfigurationSettings.AppSettings.Get( "ApplicationDir" ); string updDir = ConfigurationSettings.AppSettings.Get( "UpdateDir" ); string saveLocation = appDir + updDir + fn; Quote
Shaitan00 Posted February 1, 2005 Author Posted February 1, 2005 Using: string appDir = ConfigurationSettings.appSettings.Get( "ApplicationDir" ); I get the same error: The type or namespace name 'ConfigurationSettings' could not be found (are you missing a using directive or an assembly reference?) Seems like the problem is with ConfigurationSettings. In C# when I do "ConfigurationSettings." should a list of choices appear? Quote
mocella Posted February 1, 2005 Posted February 1, 2005 Oh, at the top of your class, add: using System.Configuration; I thought I added that in my last post, sorry. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.