UWP下载网络图片并保存在本地
private async Task<StorageFile> LoadwebImage(string uriString) { //var ImgFolder = KnownFolders.PicturesLibrary; var ImgFolder = Windows.Storage.ApplicationData.Current.LocalFolder; StorageFile SaveFile = await ImgFolder.CreateFileAsync($"{DateTime.Now.ToString("yyyy.MM.dd")}.jpg", CreationCollisionOption.OpenIfExists); using (Windows.Web.Http.HttpClient http = new Windows.Web.Http.HttpClient()) { IBuffer buffer = await http.GetBufferAsync(new Uri(uriString)); byte[] bytes = WindowsRuntimeBufferExtensions.ToArray(buffer, 0, (int)buffer.Length); using (Stream Fstream = await SaveFile.OpenStreamForWriteAsync()) { await Fstream.WriteAsync(bytes, 0, bytes.Length); } } return SaveFile; }