ConfigurationSettings.AppSettings 已过时,警告 [英] ConfigurationSettings.AppSettings is obsolete, warning
本文介绍了ConfigurationSettings.AppSettings 已过时,警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var values = new NameValueCollection
{
{ "key", ConfigurationSettings.AppSettings["API-Key"].ToString() },
{ "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) }
};
使用 app.config 文件的新方法是什么?
What's the new way to use the app.config file?
推荐答案
System.Configuration
中的 ConfigurationManager
类:
ConfigurationManager.AppSettings
ConfigurationManager.ConnectionStrings
因此您的代码将更改为:
So your code would change to:
var values = new NameValueCollection
{
{ "key", ConfigurationManager.AppSettings["API-Key"] },
{ "image", Convert.ToBase64String(File.ReadAllBytes(photo.ToString())) }
};
确保添加对 System.Configuration
的引用以及 System.Configuration
的 using
语句.
Make sure you add a reference to System.Configuration
along with the using
statement for System.Configuration
.
这篇关于ConfigurationSettings.AppSettings 已过时,警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文