• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Listing files in directory (and subdirectory)

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all,

I have some code that will return file names over a certain character count. What I am trying to do is take that to the next level and have it crawl into subfolders of that directory as well. The problem is I end up with some Frankenstein code that in the end doesn't work. Below is the working, first level of the directory code. Any tips would be great.


[ September 28, 2007: Message edited by: Mark Runals ]
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you need is a recursive method that can call itself as it descends into the directory tree. The general structure would be something like this:

[ September 28, 2007: Message edited by: Ulf Dittmer ]
 
Mark Runals
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry I should have been clearer. I understand I need to put in a recursive method. The issue I have is trying to take examples from the web and and modify them or create one myself and have it actually work - thus the Frankenstein code reference.
 
Mark Runals
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For posterity here is what I came up with. Am sure there are better ways to do this.

 
reply
    Bookmark Topic Watch Topic
  • New Topic