public bool DownloadFile(string url, string filename, string pathToSave = null) { if (string.IsNullOrWhiteSpace(pathToSave)) { pathToSave = UserDirectory.Get(); } if (string.IsNullOrWhiteSpace(filename)) { Log.Logger().LogWarning("DOWNLOAD: FileName is missing"); throw new ArgumentException("DOWNLOAD: FileName is missing"); } else { bool isValidExtension = FileProvider.CheckFileExtension(filename); if (isValidExtension) { if (WebProvider.Download(url, pathToSave, filename)) { return(true); } else { return(false); } } else { Log.Logger().LogWarning($"Check that the file \"{filename}\" has a .txt extension"); throw new ValidFileNameException($"Check that the file \"{filename}\" has a .txt extension"); } } }