C# 画像URLダウンロードでエラー

投稿者: Anonymous
private async void download()
    string[] lines = textBox2.Text.Split(new string[] { "n" }, StringSplitOptions.None);
        await DownloadImage(lines, @"C:UsersMiaDesktoptesttest");
    catch(Exception error){
        Console.WriteLine("e" + error.Message);

static async Task DownloadImage(HttpClient httpClient, string uri, string path)
    using (var res = await httpClient.GetAsync(uri, HttpCompletionOption.ResponseHeadersRead))
    using (var fileStream = File.Create(path))
    using (var httpStream = await res.Content.ReadAsStreamAsync())
        await httpStream.CopyToAsync(fileStream);

static async Task DownloadImage(string[] uris, string path)
    using (var httpClient = new HttpClient())
        await Task.WhenAll(uris.Select((uri, i) => DownloadImage(httpClient, uri, string.Format("{0}{1}.jpg", path, i + 1))));


'WindowsFormsApplication1.vshost.exe' (CLR v4.0.30319: WindowsFormsApplication1.vshost.exe): 'C:WINDOWSMicrosoft.NetassemblyGAC_MSILSystem.Net.Http.resourcesv4.0_4.0.0.0_ja_b03f5f7f11d50a3aSystem.Net.Http.resources.dll' が読み込まれました。モジュールがシンボルなしでビルドされました。
例外がスローされました: 'System.InvalidOperationException' (System.Net.Http.dll の中)
例外がスローされました: 'System.InvalidOperationException' (mscorlib.dll の中)
例外がスローされました: 'System.InvalidOperationException' (mscorlib.dll の中)

catche(Exception error)

An invalid request URI was provided. The request URI must either be an absolute URI or BaseAddress must be set.


textBox2.Text.Split(new string[] { “n” }, StringSplitOptions.None);


回答者: Anonymous

Leave a Reply

Your email address will not be published. Required fields are marked *