Exemplo n.º 1
0
        protected async Task DownloadFile(Attachment att, ISocketMessageChannel sc, string filepath)
        {
            if (File.Exists(filepath))
            {
                await sc.SendMessageAsyncSafe($"Пікча з такою назвою вже є {EmojiCodes.Tomas}").ConfigureAwait(false);

                return;
            }

            using HttpClient hc = new HttpClient();
            using FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write);
            await(await hc.GetAsync(new Uri(att.Url)).ConfigureAwait(false)).Content.CopyToAsync(fs).ConfigureAwait(false);
        }