public async Task SyncDirectory(SiteSetting site, string siteKey) { _logger.LogInformation($"Starting sync {siteKey}"); try { _client.Host = site.FtpServer; _client.Credentials = new System.Net.NetworkCredential(site.UserName, site.Password); await _client.ConnectAsync(); await _client.DownloadFolderRecursive(site.RootFolder[0], site.DestinationFolder); _logger.LogInformation($"Finish sync {siteKey}"); } catch (FtpException exc) { _logger.LogError(exc, $"Error processing site {siteKey}"); } finally { if (_client.IsConnected) { await _client.DisconnectAsync(); } } }
public async ValueTask DisposeAsync() { await _ftpClient.DisconnectAsync(); _ftpClient.Dispose(); }
/// <inheritdoc /> public Task DisposeAsync() { return(_client.DisconnectAsync()); }