将图像从图像控件存储到StorageFile
如何从Windowsapp store应用中的图像控制将图像存储到StorageFile? 我正在使用以下链接,但这对我没用
StorageFile file = await StorageFile.CreateStreamedFileFromUriAsync(" ", new Uri(user.ProfilePicUrl), new RandomAccessStream());
https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.storagefile.createstreamedfileasync.aspx
我需要明确解决我的问题。 我怎样才能做到这一点?
您可以使用以下方法将图像从URL保存到LocalFolder
的文件:
上述就是C#学习教程:将图像从图像控件存储到StorageFile分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!
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; }
本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。
ctvol管理联系方式QQ:251552304
本文章地址:https://www.ctvol.com/cdevelopment/1023700.html