elFinder 是一个基于 Web 的文件管理器,灵感来自 Mac OS X 的 Finder 程序。
elFinder.Net是.Net版本的一个Demo,使用ASP.NET MVC 4集成,可以方便的使用Web管理本地文件。
GitHub地址:
不过目前的elFinder.Net只支持管理本地文件夹,但是我需要的是管理FTP上的文件功能,在搜索一番无果后,就决定自己扩展了一下功能,让elFinder.Net也可以用来管理FTP文件。
不过自己改造的这个支持FTP的版本本来只是为满足个人需要,所以做得有些简陋,现在在这边分享一下,仅供参考:。
调用方式与原来的管理本地文件类似:
1 var ftpAction = new FtpAction("FTP地址", "FTP账号", "FTP密码"); 2 FtpFileInfo _RootFtpFileInfo = ftpAction.GetListDirectory(string.Empty).Where(p => p.Name == "FTP顶级文件夹").First(); 3 4 FTPFileSystemDriver driver = new FTPFileSystemDriver(); 5 6 var root = new FTPRoot(_RootFtpFileInfo, 7 "http://" + Request.Url.Authority + "/Files/" + folder) 8 { 9 Url = "../File/OpenFile?Path=",10 IsReadOnly = false, // Can be readonly according to user's membership permission11 Alias = "文件服务器", // Beautiful name given to the root/home folder12 MaxUploadSizeInMb = 50, // Limit imposed to user uploaded file 13 LockedFolders = new List(new string[] { "Folder1" }),14 FTPServerIP = "FTP地址",15 FTPUser = "FTP账号",16 FTPPassword = "FTP密码"17 };18 driver.AddRoot(root);19 var connector = new Connector(driver);20 21 return connector.Process(this.HttpContext.Request);