delferns2001
delferns2001
CC#
Created by delferns2001 on 1/9/2023 in #help
❔ Creating a hierarchy algorithm
I have an image model, which consists of public Guid Id { get; set; } public string Name { get; set; } public List<string> VirtualDir { get; set; } virtual dir is the directory the image is stored in, split into a list of strings so one example: ["folder1","folder1child", "image"] Now, if i want to create a Hierarchy of the whole directory showing all images in the different folders represented as JSON, something like the below. { text: 'Folder 1', children: [{ name: 'image 1' }, { name: 'image 2' }, { name: 'image 2' }], }, { text: 'Folder 2', children: [ { name: 'folder 2 child folder', children: [{ name: 'image 1' }] }, { name: 'image 2' }, { name: 'image 2' }, ], }, How can i successfully archive this?
6 replies