ConfigurationSettings.AppSettings is obsolete, warning

后端 未结 4 468
眼角桃花
眼角桃花 2021-01-03 00:51
var values = new NameValueCollection
{
    { \"key\", ConfigurationSettings.AppSettings[\"API-Key\"].ToString() },
    { \"image\", Convert.ToBase64String(File.ReadA         


        
4条回答
  •  离开以前
    2021-01-03 01:43

    The ConfigurationManager class in System.Configuration:

    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())) } 
    }; 
    

    Make sure you add a reference to System.Configuration along with the using statement for System.Configuration.

提交回复
热议问题