字符串 url1 = "http://localhost/Images/Map.png";
我想从此链接加载图像“Map.png”,然后保存到独立存储。
问问题
504 次
2 回答
0
这对 Windows 8 手机很有用
http://code.msdn.microsoft.com/wpapps/CSWP8ImageFromIsolatedStora-8dcf8411
于 2013-11-16T06:06:15.307 回答
0
公共无效GetImages()
{
WebClient m_webClient = new WebClient();
Uri m_uri = new Uri("http://localhost/Images/Map.png");
m_webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(webClient_OpenReadCompleted);
m_webClient.OpenReadAsync(m_uri);
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
int count;
Stream stream = e.Result;
byte[] buffer = new byte[1024];
使用 (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication())
{
// isf.Remove();
//if (!isf.FileExists("map"))
//{
using (System.IO.IsolatedStorage.IsolatedStorageFileStream isfs = new IsolatedStorageFileStream("map", FileMode.Create, isf))
{
count = 0;
while (0 < (count = stream.Read(buffer, 0, buffer.Length)))
{
isfs.Write(buffer, 0, count);
}
stream.Close();
isfs.Close();
}
}
于 2012-05-09T10:32:39.007 回答