elFinder 是一個基於 Web 的文件管理器,靈感來自 Mac OS X 的 Finder 程序。
elFinder.Net是.Net版本的一個Demo,使用ASP.NET MVC 4集成,可以方便的使用Web管理本地文件。
GitHub地址:https://github.com/leniel/elFinder.Net
不過目前的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 permission 11 Alias = "文件服務器", // Beautiful name given to the root/home folder 12 MaxUploadSizeInMb = 50, // Limit imposed to user uploaded file 13 LockedFolders = new List<string>(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);
