-
-
Notifications
You must be signed in to change notification settings - Fork 176
Open
Labels
Description
OS:win10
public static void Main(string[] args)
{
var services = new ServiceCollection();
// use %TEMP%/TestFtpServer as root folder
/*services.Configure<DotNetFileSystemOptions>(opt => opt
.RootPath = Directory.GetCurrentDirectory());*/
// Add FTP server services
// DotNetFileSystemProvider = Use the .NET file system functionality
// AnonymousMembershipProvider = allow only anonymous logins
services.AddFtpServer(builder => builder
.UseUnixFileSystem() // Use the .NET file system functionality
.EnableAnonymousAuthentication()); // allow anonymous logins
// Configure the FTP server
services.Configure<FtpServerOptions>(opt => opt.ServerAddress = "127.0.0.1");
// Build the service provider
using (var serviceProvider = services.BuildServiceProvider())
{
// Initialize the FTP server
var ftpServerHost = serviceProvider.GetRequiredService<IFtpServerHost>();
// Start the FTP server
ftpServerHost.StartAsync(CancellationToken.None).Wait();
Console.WriteLine("Press ENTER/RETURN to close the test application.");
Console.ReadLine();
// Stop the FTP server
ftpServerHost.StopAsync(CancellationToken.None).Wait();
}
}
run result:
System.InvalidOperationException:“Unable to resolve service for type 'Microsoft.Extensions.Logging.ILoggerFactory' while attempting to activate 'FubarDev.FtpServer.FileSystem.Unix.UnixFileSystemProvider'.”
After modifying the UseDotNetFileSystem method to the UseUnixFileSystem method, I received an error message.
I developed a device that is not a Udisk but a custom USB device. Then I developed the c#library, which provides interfaces such as mkdir, open, write, close, etc. The library has a file system catalog style of UNIX (e.g. /home/test), and I want to modify the code of FubarDev.FtpServer.FileSystem.Unix:
Eg:
Public Task UnlinkAsync (IUnixFileSystemEntry entry, CancellationToken cancellationToken)
{
FatFsFuseLib.Unlink(....);
}