What I want to do is I want to maintain a profile pic for my user in my app. The user can pic from the local Pictures library. So whenever the app loads it should check in local app data whether a pic is there or not, if exists it should set the image to it. I tried doing like this but it isn't working.
// Saving
BitmapImage bitmapImage = image.Source as BitmapImage;
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
string path = bitmapImage.UriSource.ToString();
localSettings.Values["ProfilePic"] = path;
// In constructor retrieving like this.
string sourceVal = localSettings.Values["ProfilePic"] as string;
if (sourceVal != null) {
Image img = new Image();
BitmapImage bi = new BitmapImage();
Uri uri = new Uri(sourceVal);
bi.UriSource = uri;
img.Source = bi;
}
It's throwing exceptions, can anyone give em the appropriate code using C#?
System.NullReferenceException
occurred.