private void UpdateBeerLabel(Beer beer) { BeerLabel = null; if (!untappdService.IsUNTPProject() || String.IsNullOrEmpty(beer.LabelUrl)) { return; } string labelPath = untappdService.GetBeerLabelFilePath(beer); if (Path.GetFileNameWithoutExtension(labelPath).Equals(DefautlValues.DefaultBeerLabelName)) { return; } if (!File.Exists(labelPath)) { string directoryName = Path.GetDirectoryName(labelPath); if (!Directory.Exists(directoryName)) { FileHelper.CreateDirectory(directoryName); } webDownloader.DownloadFile(beer.LabelUrl, labelPath); } BeerLabel = ImageConverter.GetBitmapSource(labelPath); }
private void DownloadFile(string webPath, string filePath) { if (!String.IsNullOrEmpty(webPath) && !File.Exists(filePath)) { string directoryName = Path.GetDirectoryName(filePath); if (!Directory.Exists(directoryName)) { FileHelper.CreateDirectory(directoryName); } webDownloader.DownloadFile(webPath, filePath); } }
public string DownloadFile( string outputFilename, string expectedChecksumMd5, string url, bool forceDownload = false) { var filePath = Path.Combine(Path.GetTempPath(), outputFilename); if (File.Exists(filePath) && string.Equals( FileHelper.CalculateChecksum(filePath), expectedChecksumMd5, StringComparison.OrdinalIgnoreCase) && !forceDownload) { return(filePath); } Trace.WriteLine($"{outputFilename} not found. Attempting to download {outputFilename}"); var tempFile = Path.Combine(Path.GetTempPath(), $"{Guid.NewGuid()}.jar"); downloader.DownloadFile(url, tempFile); Trace.WriteLine($"{outputFilename} downloaded successfully"); MoveFile(filePath, tempFile); return(filePath); }
// Download Profile Image public bool DownloadProfileImage(IUserDTO userDTO, string filePath, ImageSize imageSize = ImageSize.normal) { var url = _userQueryGenerator.DownloadProfileImageURL(userDTO, imageSize); return(_webDownloader.DownloadFile(url, filePath)); }