0

I want to use FluentFTP in .NET6. Is there best practice to add FluentFtp.FtpClient to IServiceCollection? Is there any implementation like IHttpClientFactory & AddHttpClient?

I tried the following code. It works but not best.

Some my wrapper

public class MyFtpClient
{
   private readonly FluentFTP.FtpClient _client;

   public MyFtpClient(MyFtpClientSettings settings)
   {
       _client = new FtpClient(); // create instance with settings
   }
}

In Porgram.cs

services.AddScoped(x => new MyFtpClient(settings); 
  • What does `It works but not best.` mean? – burnsi Jan 30 '23 at 10:19
  • I guess it better to implement a factory for FtpClient like IHttpClientFactory. Using FtpClient directly may cause some sockets exhaustion. https://learn.microsoft.com/en-us/dotnet/architecture/microservices/implement-resilient-applications/use-httpclientfactory-to-implement-resilient-http-requests – mclemore_oto Jan 31 '23 at 06:05

0 Answers0