AvalonStudio.Controls.Standard.WelcomeScreen.WelcomeScreenViewModel.SaveThumbnail C# (CSharp) Method

SaveThumbnail() private method

private SaveThumbnail ( string youtubeID ) : Task
youtubeID string
return Task
        private async Task<IBitmap> SaveThumbnail(string youtubeID)
        {
            var savePath = Path.Combine(Platform.CacheDirectory, "videoFeed", youtubeID + ".png");

            if (!Directory.Exists(Path.Combine(Platform.CacheDirectory, "videoFeed")))
            {
                Directory.CreateDirectory(Path.Combine(Platform.CacheDirectory, "videoFeed"));
            }

            if (File.Exists(savePath))
            {
                return new Bitmap(savePath);
            }

            var thumbnail = "https://i4.ytimg.com/vi/" + youtubeID + "/hqdefault.jpg";

            using (WebClient client = new WebClient())
            {
                await client.DownloadFileTaskAsync(new Uri(thumbnail), savePath);
            }

            return new Bitmap(savePath);
        }