This is a migrated thread and some comments may be shown as answers.

Clearing Settings - return to default

1 Answer 82 Views
PersistenceFramework
This is a migrated thread and some comments may be shown as answers.
Tyree
Top achievements
Rank 2
Tyree asked on 26 Sep 2011, 07:47 PM
We have a composite application and each module can and will load in xaml pages as needed and I would like the ability to save the settings for a given page, not just everything loaded. Likewise I need the ability to delete stored settings for only a given page and not all stored settings.

Some of this seems doable with a stream but I was currently using IsolatedStorage.

Any ideas?

1 Answer, 1 is accepted

Sort by
0
Alex Fidanov
Telerik team
answered on 29 Sep 2011, 07:20 AM
Hi Tyree,

The IsolatedStorageProvider uses the PersistenceManager's storage, which holds all of the controls marked with the StorageId propery. You can access this storage with the PersistenceManager.GetStorage() static method. If you want to save only certain files, you could remove the control that are not to be saved from that storage and call SaveToStorage method.

In regards to deleting only specific settings, you can access the isolated storage with the GetIsolatedStoreOverride method of the IsolatedStorageProvider. Please note that this method is protected and you have to subclass the provider to use it. For example, you can extend this class in the following way:

public class IsolatedStorageProviderEx : IsolatedStorageProvider
{
    public void DeleteFile(string file)
    {
        var store = this.GetIsolatedStoreOverride();
        using (store)
        {
            if (store.FileExists(file))
                store.DeleteFile(file);
        }
    }
}
Please note that the file's extension is ".bin". With the upcoming versions, the extension will be exposed as a property of the provider.

Best wishes,
Alex Fidanov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
PersistenceFramework
Asked by
Tyree
Top achievements
Rank 2
Answers by
Alex Fidanov
Telerik team
Share this question
or