String url1 =“http://localhost/Images/Map.png”;
我想从此链接加载图像“Map.png”,然后保存到隔离存储。
答案 0 :(得分:0)
public void 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();
}
}
答案 1 :(得分:0)
这对于Windows 8手机非常有用
http://code.msdn.microsoft.com/wpapps/CSWP8ImageFromIsolatedStora-8dcf8411