uwpraspberry-pi3uwp-xamlwindows-10-iot-coreresource-file

How to Full Control (Read/Write) of custom resource resw file (Universal Windows)


How can I read/write Keys/Values on a custom Resource File (resw) (storing string and conditional resources) ?

I added Resource File(resw) for storing settings of app. And Then ?

 private void button1_Click(object sender, RoutedEventArgs e)
    {
        ResourceContext resourceContext = ResourceContext.GetForViewIndependentUse();
        ResourceMap resourceMap = ResourceManager.Current.MainResourceMap.GetSubtree("Resources");//resources.resw accessing in root is ok.
        var resourceValue = resourceMap.GetValue("PicPath", resourceContext);

        resourceMap.SetValue("DBPath", resourceContext,"PicPath2");//no write avaible ? ERROR LINE
    }

Solution

  • To store read / write app values, you should use the ApplicationData API. You can have local and / or roaming settings.

    Resources are read-only and are for things like UI strings, images, etc. that you load at runtime and might want to change based on things like the user's language, the accessibility settings, the display's scale factor, etc.