我有一个Windows Phone 7应用程序,已经在商店多年了。它安装在WP 7.x,8.0和8.1设备上。我将应用程序转换为WP8.1目标,因此我可以使用较新的Microsoft AdControl(旧版本会在年底停止投放广告)。这意味着我将需要开始使用ApplicationData.Current.LocalFolder读取/写入数据,而不是使用旧的IsolatedStorageFile.GetUserStoreForApplication()。WP7到WP8.1应用程序更新。 WP8.1 ApplicationData是否会访问使用WP7 IsolatedStorageFile存储的相同数据?
我的用户有很多使用IsolatedStorageFile.GetUserStoreForApplication()存储的数据。如果他们将应用程序升级到WP8.1版本,我想确保它们不会丢失任何这些数据,并且仍然可以使用ApplicationData.Current.LocalFolder访问数据。
任何人都可以证实这种情况吗?
这是我如何WP7写道数据:
using (IsolatedStorageFile applicationStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
using (IsolatedStorageFileStream file = applicationStorage.OpenFile(filename, FileMode.Create, FileAccess.Write))
{
using (StreamWriter sw = new StreamWriter(file))
{
sw.WriteLine("some data goes here");
}
}
}
这是怎么了,我将读取数据在WP8.1:使用独立存储
using (Stream stream = await ApplicationData.Current.LocalFolder.OpenStreamForReadAsync(filename))
{
using (StreamReader sr = new StreamReader(stream))
{
String line = sr.ReadLine();
// Do something with line
}
}
感谢GeoIT,特别是关于PhoneProductId的额外部分。 – Jared