So laden Sie Dateien mit UWP in c # @ herunt
Ich bin ein Anfänger in der Programmierung und ich habe mich gefragt, wie man Dateien in UWP richtig herunterlädt. Ich verwende dies jetzt, aber es funktioniert nur in 50% der Fälle:
public async Task StartDownload()
{
try
{
StorageFile sf = await DownloadsFolder.CreateFileAsync(title.Text, CreationCollisionOption.GenerateUniqueName);
downloadFolder = (await sf.GetParentAsync()).ToString();
HttpClient client = new HttpClient();
byte[] buffer = await client.GetByteArrayAsync(inputURL);
using (Stream stream = await sf.OpenStreamForWriteAsync())
{
stream.Write(buffer, 0, buffer.Length);
}
path = sf.Path;
}
catch (Exception e)
{
MessageDialog dialog = new MessageDialog("Sorry, something went wrong...", "An error...");
await dialog.ShowAsync();
}
}
Die Ausnahme lautet: "Unbehandelte Ausnahme bei 0x750F6D7E (combase.dll in program.exe 0xC000027B; Eine anwendungsinterne Ausnahme ist aufgetreten (Parameter: 0x16E73128, 0x00000001)."
Danke im Vorau