1
我試圖將圖像從網絡保存到本地存儲以便以後處理,但它看起來已損壞,並試圖用外部應用程序打開它失敗。在瀏覽器中打開圖像完全正常工作。謝謝你的幫助。使用HttpClient下載的圖像已損壞
var client = new HttpClient();
var clientResponse = await client.GetByteArrayAsync(imageUri);
var temp = ApplicationData.Current.TemporaryFolder;
StorageFile file;
if ((await temp.GetFilesAsync()).Any(f => f.Name == "temp_image.png")) {
file = await temp.GetFileAsync("tempcolorizer.png");
} else {
file = await temp.CreateFileAsync("temp_image.png");
}
using (var fs = await file.OpenReadAsync())
using (var writer = new DataWriter(fs)) {
writer.WriteBytes(clientResponse);
}