示例#1
0
        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();
                }
            }
        }
示例#2
0
        public async ValueTask DisposeAsync()
        {
            await _ftpClient.DisconnectAsync();

            _ftpClient.Dispose();
        }
示例#3
0
 /// <inheritdoc />
 public Task DisposeAsync()
 {
     return(_client.DisconnectAsync());
 }