将图像从图像控件存储到StorageFile

如何从Windowsapp store应用中的图像控制将图像存储到StorageFile? 我正在使用以下链接,但这对我没用

StorageFile file = await StorageFile.CreateStreamedFileFromUriAsync(" ", new Uri(user.ProfilePicUrl), new RandomAccessStream()); 

http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.createstreamedfileasync.aspx

我需要明确解决我的问题。 我怎样才能做到这一点?

您可以使用以下方法将图像从URL保存到LocalFolder的文件:

 public async Task DownloadFileAsync(Uri uri, string filename) { using (var fileStream = await ApplicationData.Current.LocalFolder.OpenStreamForWriteAsync(filename, CreationCollisionOption.ReplaceExisting)) { var webStream = await new HttpClient().GetStreamAsync(uri); await webStream.CopyToAsync(fileStream); webStream.Dispose(); } return (await ApplicationData.Current.LocalFolder.GetFileAsync(filename)).Path; }