Reputation: 2658
I'm trying to store a list of folders to be able to reach them afterwards. (I've previously added them to FutureAccessList
)
List<StorageFolder> folders = new List<StorageFolder>();
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
// ...
Windows.Storage.ApplicationDataCompositeValue data = new Windows.Storage.ApplicationDataCompositeValue();
foreach (var item in folders)
{
if (item.Path == null || item.Path == "")
continue;
data[item.FolderRelativeId] = item.Path; // this is the line where I get the exception
}
localSettings.Values["folders"] = data;
I don't understand why I keep receiving this error:
An exception of type 'System.Exception' occurred in mscorlib.dll but was not handled in user code
WinRT information: Error trying to write setting in application data composite value
Somebody can help me ?
Upvotes: 1
Views: 339
Reputation: 69
ApplicationDataCompositeValue not needed.
foreach (AccessListEntry entry in StorageApplicationPermissions.FutureAccessList.Entries)
{
StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(entry.Token);
}
Upvotes: 2
Reputation: 2658
I eventually managed to make it work:
I incremented a variable and made this variable the key of the DataCompositeValue... item.FolderRelativeId
seemed to have some special/forbidden characters in it.
List<StorageFolder> folders = new List<StorageFolder>();
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
// ...
Windows.Storage.ApplicationDataCompositeValue data = new Windows.Storage.ApplicationDataCompositeValue();
var i = 0;
foreach (var item in folders)
{
if (item.Path == null || item.Path == "")
continue;
data[i.ToString()] = item.Path; // this is the line where I get the exception
i = i + 1;
}
localSettings.Values["folders"] = data;
Upvotes: 0