1

some of my web applications write to the disk on the web server. The paths change depending on location, prod and dev, etc. I used to store the paths in web.config under configuration / appSettings like:

<add key='PDFOutPutPath'   value='C:\Temporary_Web_Files\PDFTempDocs\'/>

And then get them like this:

path = ConfigurationSettings.AppSettings('PDFOutPutPath')

Now in .Net 4, I get compile warnings about this being depreciated, so I found some instructions telling me to add a configuration file, move my values to it like so:

<configuration> 
 <appSetings> 
    <add key='PDFOutPutPath'   value='C:\Temporary_Web_Files\PDFTempDocs\'/>
 </appSettings>
</configuration> 

and use configuration manager like so:

ConfigurationManager.AppSettings( 'PDFOutPutPath' )

However, this does not work. I'm not sure if I'm supposed to be using the configuration manager for this or not - If not, where do you put stuff like this? I have System.Configuration referenced, so this in not my issue.

4

1 回答 1

0

因此,您遵循的说明似乎有点误导。

您不需要第二个文件,您应该删除 app.config 文件。您可以将所有配置值放在 web.config 中。只要确保配置项在<appSetings>节点中。但是您应该继续在代码中使用 ConfigurationManager 类来访问这些值。

于 2012-06-20T18:47:15.550 回答