Recent

Author Topic: Store directories and files  (Read 323 times)

LemonParty

  • Sr. Member
  • ****
  • Posts: 391
Store directories and files
« on: November 16, 2025, 02:15:11 pm »
Hello.

I want to store a tree structure of files and directories. What class is suitable for this?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

jamie

  • Hero Member
  • *****
  • Posts: 7402
Re: Store directories and files
« Reply #1 on: November 16, 2025, 03:44:08 pm »
I am afraid you may need to write something? 8)

You could use the FindAllFiles then separate the repeating Directory entries and build a tree file from that, I've done that before using spaces to the left to indicate the depth of the tree.

 You could also use the TShellTreeView which allows you to write out to a stream the tree, and you can force it to view all files, however, there is an issue to that component, it only writes out what is visible in the tree.
  I suppose you could scan the tree and expand all of the childs so they will be visible and then write it.

Personally myself, I find using a FindFirst ...... and FindNext with some nesting works just fine to build a text tree file.

Jamie
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 7402
Re: Store directories and files
« Reply #2 on: November 16, 2025, 11:11:54 pm »
I made a Demo program which uses the "TFileSearcher" class. It populates a TstringList within itself and the Demo displays that contents to a MEMO, but you can send that to wherever.


The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018