c# - localSettings.Containers[containername] - The given key was not present -


i looping through code looking localsettings. when container null gives error message "the given key not present in dictionary". how can check see container null doesn't crash code?

if ((windows.storage.applicationdatacontainer)localsettings.containers[containername] != null) 

this gives same error

var container = localsettings.containers[containername]; 

windows.storage.applicationdatacontainer settings = windows.storage.applicationdata.current.localsettings;          //this checks if given container name exists or not         if(settings.containers.containskey("containername"))         {              if(settings.containers["containername"].values.containskey("your data key"))             {                 //do             }         } 

hope helps


Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

Cross-Compiling Linux Kernel for Raspberry Pi - ${CCPREFIX}gcc -v does not work -

java.lang.NoClassDefFoundError When Creating New Android Project -