0

One of my Java programs lists all of the files and folders in a root directory and then highlights the directories. It therefore runs the File.IsDirectory() method on each file to determine the colour of the list item. However, I have noticed a very significant performance issue when this check is added. Is there any way to overcome this.

I have considered somehow implementing the dir Windows command and comparing the output. However, I am not really sure how to do this because of the extra information outputted by the command. Plus, I would like my application to run on Mac OSX too.

Andy
  • 3,600
  • 12
  • 53
  • 84
  • It would likely been better to improve the performance somewhere else, such as querying files lazily. – Paul Draper Nov 16 '13 at 20:27
  • @PaulDraper what do you mean by querying files lazily? I also have to check because I need an option not to display directories in the list – Andy Nov 16 '13 at 20:30
  • @Andy, if you were displaying these nested recursively, you would not find if something was a directory until the user had gotten to that point. I'm not sure what your application is, so that may not apply. – Paul Draper Nov 16 '13 at 20:45
  • @PaulDraper I see. No. It is basically a graphical version of `dir` so everything needs to be displayed at once – Andy Nov 16 '13 at 20:47
  • Well, you can thread off the actual scanning so that it runs in parallel with the GUI display, but you have to be careful. The 'normal' WIndows GUI components, TreeView etc, cannot keep up and the GUI input queue fills up with messages very quicky, effectively stuffing the GUI response. – Martin James Nov 16 '13 at 21:11
  • @MartinJames I already do this task in a new thread; this is not the problem. I started this question because I realized that the actual retrieval of files was considerably fast but determining whether they were directories and not was the slow part and I wanted to know if there was any method/work around to over come this without only listing files and folders in a directory like Windows Explorer does. – Andy Dec 22 '13 at 12:40

0 Answers0