Problem in getting files in a directory

  • Thread starter Thread starter Hemant
  • Start date Start date
H

Hemant

Hi,

We are getting "Out of Memory" exception while using Directory.GetFiles()
method if there are large number of files present in the directory on which
the method is being executed.

We would like to have an alternate solution for picking files from the
directory, like picking only 10 or 15 files at a time.

Is there anything in GetFiles() method with which we can tweak in its
functionality to pick only a certain number of files? Or if there's an
alternate solution for the same, please do let us know.



Thanks,

Hemant
 
Is there anything in GetFiles() method with which we can tweak in its
functionality to pick only a certain number of files? Or if there's an
alternate solution for the same, please do let us know.

Are you using Directory or DirectoryInfo. the info classes are much less
weighty. I am not sure this will solve the problem, as both should just
get the names.

In the 4.0 Framework, there are more efficient file manipulation
methods, but that means heading into a beta to get your answer. There is
a "Go Live" on beta 2, but it is still beta.

Peace and Grace,

--
Gregory A. Beamer

Vote for Miranda's Christmas Story
http://tinyurl.com/mirandabelieve

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Hi,
Actually, in our case, its more than 5000 files that client puts in the
directory and after that our windows service picks up those files to
process.


Also, the search criteria filter does not help much because the filenames
are almost similar i.e. starting with same letters/words.

Is there any other option that we can use to avoid this memory issue?

thanks,
Hemant
 
Back
Top