Parsing large text file

Hello. I have a massive text file containing many thousands of directory and file names with / at the root, like so:


I need to parse the file in such a way that I can create a filesystem hierarchy as if I were enumerating files/directories. Ultimately I want to add these to a tree gui control with everything under its proper node without duplicating anything. It should look roughly like so:


I can open the file and add nodes/children to the tree control but how should I go about doing the actual parsing? How can I find a filename and say "this belongs under this node"? I want to do this efficient as possible even if I must use multiple threads.

Any advice/resources would be appreciated
Given the amount of pathnames in the file I will have to add and remove nodes dynamically and that is where my main struggle is. If I add all root nodes then when a node is expanded I have to find what belongs under it and add them and so on for each subdirectory.
Topic archived. No new replies allowed.