public static RemoteFolder Create(FtpListItem fd) { var res = new RemoteFolder(); res.File = fd; res.SetPath(fd.FullName); return(res); }
public void Create() { var dt = new DateTime(2018, 1, 2, 3, 0, 0); var f = new FtpListItem(); f.FullName = $"{Root}\\{dt.Year}\\{dt.Month}\\{dt.Day}\\{dt.Hour}"; var actual = new RemoteFolder { Path = f.FullName, File = f, YyyyMMddHH = dt }; var res = RemoteFolder.Create(f); AreEqual(actual, res); }
public static List <RemoteFolder> GetAllHoursFolders(FtpClient client, string folder, Func <Folder, bool> func = null) { var res = new List <RemoteFolder>(); void AddFolders(FtpListItem f, int recurs) { if (f.Type != FtpFileSystemObjectType.Directory) { return; } if (recurs == 0) { RemoteFolder item = Create(f); if (func == null) { res.Add(item); } else { if (func(item)) { res.Add(item); } } } else { foreach (FtpListItem y in client.GetListing(f.FullName)) { AddFolders(y, recurs - 1); } } } // 1 2 3 4 // yyyy MM dd HH AddFolders(new FtpListItem { FullName = folder, Type = FtpFileSystemObjectType.Directory }, 4); return(res); }