【发布时间】:2012-03-09 00:41:20
【问题描述】:
在我的 WP7 应用程序中,我从 Web 下载了 200 张图像并保存在隔离存储中。调试时,所有图像都通过队列方法加载到全景视图中,我可以在连接到 pc 时查看。当我打开应用程序并浏览图像时将其与电脑断开连接后,它会显示一些图像并终止。
if (i < 150)
{
WebClient m_webClient = new WebClient();
Uri m_uri = new Uri("http://d1mu9ule1cy7bp.cloudfront.net/2012//pages/p_" + i + "/mobile_high.jpg");
m_webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
m_webClient.OpenReadAsync(m_uri);
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
int count;
try
{
Stream stream = e.Result;
byte[] buffer = new byte[1024];
using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
//isf.Remove();
using (System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("IMAGES" + loop2(k) + ".jpg", FileMode.Create, isf))
{
count = 0;
while (0 < (count = stream.Read(buffer, 0, buffer.Length)))
{
isfs.Write(buffer, 0, count);
}
stream.Close();
isfs.Close();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
【问题讨论】:
-
你能给我们一些你使用isolatedStorage的代码吗,...?
-
是的,仅在真实设备中..我已经在全景视图中加载了图像,首先从 iso 商店添加了 3 张图像,并使用选择更改事件删除了第一张图像并添加了第四张图像。
标签: silverlight-4.0 windows-phone-7.1 windows-phone-7 isolatedstorage