Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Listing files in directory (and subdirectory)  RSS feed

 
Mark Runals
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • 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 ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
For posterity here is what I came up with. Am sure there are better ways to do this.

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!