-1

If I have a directory structure like so on a web service that sends me a list of files and folders in the directory I request. How would you go about iterating through the entire structure. There is no recursive search, so each directory has to be pulled one at a time. I can get the directories content I request but it doesnt list any sub-directories information. I was trying to think of a way to do this with a for loop or for each loop, but I havent been able to come up with anything. I didnt write the web service so I cant include recursive directory searching in it.

Pictures
    photo1.png
    photo2.png
    TestFolder1
        April.png
        MyPictures
             ProfilePic.png
    TestFolder2
        2012
            August
                Photos
                    photo3.png
                    photo4.png
Marc
  • 16,170
  • 20
  • 76
  • 119
ios85
  • 2,104
  • 7
  • 37
  • 55
  • So you have to do the recursive search at your end then. For each directory you have in the response list, you then call again to request the contents of it. the same logic applies as to if you were doing the recursive search on the file system directory – musefan Nov 08 '12 at 14:27
  • 1
    I think this is a legitimate question and I'd like to know why this has been downvoted. Does the downvoter care to comment? – Dennis Traub Nov 08 '12 at 14:37

1 Answers1

3

Your probably looking for a Tree Traversal Algorithm:

Community
  • 1
  • 1
Dennis Traub
  • 50,557
  • 7
  • 93
  • 108