我想從網上下載圖像將其保存在媒體庫中,下面是我的代碼,我在這裏缺少的東西,在此先感謝從網絡下載圖像並存儲在媒體庫(Windows Phone 8)
public void storePicture()
{
try
{
using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
string url = @"http://mynokiablog.com/wp-content/uploads/2012/11/wp8.jpeg";
BitmapImage storeimage = new BitmapImage(new Uri(url));
// height and width are 0
int testheight = storeimage.PixelHeight;
int testwidth = storeimage.PixelWidth;
IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile("testname");
// NullRefrenceException
WriteableBitmap wb = new WriteableBitmap(storeimage);
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 0, 85);
fileStream.Close();
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine(ex.Message);
}
}
嗨流明我不想使用Web客戶端,我已經發布與BitmapImage的解決方案 – 2013-03-06 08:15:55