You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Setup dependency injectionvarservices=newServiceCollection();// use %TEMP%/TestFtpServer as root folderservices.Configure<DotNetFileSystemOptions>(opt =>opt.RootPath=Path.Combine(Path.GetTempPath(),"TestFtpServer"));// Add FTP server services// DotNetFileSystemProvider = Use the .NET file system functionality// AnonymousMembershipProvider = allow only anonymous loginsservices.AddFtpServer(builder =>builder.UseDotNetFileSystem()// Use the .NET file system functionality.EnableAnonymousAuthentication());// allow anonymous logins// Configure the FTP serverservices.Configure<FtpServerOptions>(opt =>opt.ServerAddress="127.0.0.1");// Build the service providerusing(varserviceProvider=services.BuildServiceProvider()){// Initialize the FTP servervarftpServerHost=serviceProvider.GetRequiredService<IFtpServerHost>();// Start the FTP serverftpServerHost.StartAsync(CancellationToken.None).Wait();Console.WriteLine("Press ENTER/RETURN to close the test application.");Console.ReadLine();// Stop the FTP serverftpServerHost.StopAsync(CancellationToken.None).Wait();}