/// <summary> /// Returns a non-recursive list of files/folders inside the specified path /// </summary> /// <param name="cpath">path to folder to list inside</param> /// <param name="skipIgnored">if true, ignored items are not returned</param> public override IEnumerable <ClientItem> List(string cpath, bool skipIgnored = true) { ListingFailed = false; UnsetKeepAlive(); List <ClientItem> list = new List <ClientItem>(); lock (ftpcLock) { bool ok = false; while (!ok) { try { if (_controller.Client.WorkingDirectory.CompareTo(_controller.Paths.Remote) != 0) { _controller.Client.WorkingDirectory = _controller.Paths.Remote; } Notifications.ChangeTrayText(MessageType.Scanning, null, 0, cpath); var Listed = _ftpc.GetListing(cpath, FtpListOption.Size); list = Array.ConvertAll(new List <FtpListItem>(Listed).ToArray(), ConvertItem).ToList(); ok = true; } catch (TimeoutException ex) { Common.LogError(ex); } catch (Exception ex) { Common.LogError(ex); yield break; } } } list.RemoveAll(x => x.Name == "." || x.Name == ".."); foreach (var f in list.Where(x => x.Type != ClientItemType.Other)) { yield return(f); } SetKeepAlive(); }
/// <summary> /// Returns a non-recursive list of files/folders inside the specified path /// </summary> /// <param name="cpath">path to folder to list inside</param> /// <param name="skipIgnored">if true, ignored items are not returned</param> public IEnumerable <ClientItem> List(string cpath, bool skipIgnored = true) { ListingFailed = false; UnsetKeepAlive(); var list = new List <ClientItem>(); try { if (FTP) { list = Array.ConvertAll(new List <FtpListItem>(_ftpc.GetListing(cpath)).ToArray(), ConvertItem).ToList(); } else { list = Array.ConvertAll(new List <SftpFile>(_sftpc.ListDirectory(cpath)).ToArray(), ConvertItem).ToList(); } } catch (Exception ex) { Common.LogError(ex); ListingFailed = true; yield break; } list.RemoveAll(x => x.Name == "." || x.Name == ".."); if (skipIgnored) { list.RemoveAll(x => x.FullPath.Contains("webint")); } foreach (var f in list.Where(x => x.Type != ClientItemType.Other)) { yield return(f); } SetKeepAlive(); }