c# - 将列表(String)保存到应用程序/隔离存储(Win8.1)

标签 c# windows windows-8 windows-8.1 isolatedstorage

我有一个包含多个字符串的列表,我想将其保存到 IsolatedStorage。做一些显而易见的事情,比如

List<string> l = new List<string>();
ApplicationData.Current.LocalSettings.Values["locations"] = l;

导致 Data of this type is not supported 错误。

据我所知,为 WP8 silverlight 改编此代码效果很好。我做错了什么?

最佳答案

ApplicationData.Current.LocalSettings仅支持 base data types .

想想如果你有一个简单的List<string> ,您可以使用 Linq:

List<string> l = new List<string>(); // your list with strings
ApplicationData.Current.LocalSettings.Values["locations"] = l.ToArray();
// then when you want to retrive it:
List<string> lret = ((string[])ApplicationData.Current.LocalSettings.Values["locations"]).ToList();

关于c# - 将列表(String)保存到应用程序/隔离存储(Win8.1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25151275/

相关文章:

javascript - Windows 8 上的 Firefox 报告为触摸设备

javascript - 通过 Javascript 在 Windows Metro 应用程序中打开 url

c# - 为什么在命名空间外引用的类型需要完全限定?

windows - 如何在 Windows 上使用 GNU Make?

windows - QueryWorkingSet 在其结果中包含无效页面

java - 如何只获取窗口的可见部分(Windows、gdi32、user32 等)

c# - 绑定(bind)到 WPF 中的依赖项和常规属性

c# - System.TypeLoadException : Method 'Create' in type 'MySql.Data.EntityFrameworkCore.Query.Internal.MySQLSqlTranslatingExpressionVisitorFactory'

c# - protobuf-net:序列化和反序列化带有长度前缀的可空枚举时的 ProtoException

c# - 在运行时设置应用栏按钮的图像