MyDear Techies,
How to write getfiles() method to fetch only few (100 or 1000... ) files from a directory .
Please provide the solution ........:)
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2013, 9:39 AM EDT
' ....
amShekar42 reputationPosted Apr 1, 2013, 11:32 AM EDT
For older frameworks ?
VulpesRank #55 · 29.2K reputationPosted Apr 1, 2013, 11:54 AM EDT
amShekar42 reputationPosted Apr 1, 2013, 10:52 PM EDT
Thanks for your reply it is working in 4.0 frame work.
My existed application in 2.0. How can we handle plz reply me :)
VulpesRank #55 · 29.2K reputationPosted Apr 2, 2013, 2:54 AM EDT
amShekar42 reputationPosted Apr 2, 2013, 3:44 AM EDT
But in My.computer.Filesystem the enumeratefiles didnt find there i can find getfiles only
how can we tackle
thanks in advance vuples
VulpesRank #55 · 29.2K reputationPosted Apr 2, 2013, 4:12 AM EDT
It only has GetFiles which returns a ReadOnlyCollection rather than an array of the file names. The former is effectively a read-only wrapper for the latter.
So, if you want to use this functionality, you'll have to use the System.IO.Directory.EnumerateFiles method instead.
amShekar42 reputationPosted May 3, 2013, 1:26 AM EDT
i.e i have one folder containing 50000 files every thread calling 1500 files
will it achieve my requirement
VulpesRank #55 · 29.2K reputationPosted May 3, 2013, 4:58 AM EDT
Here's a quick example of using AsParallel which is applied to the collection to be parallelized:
Notice that there are issues in using Take, Skip etc. in a parallel query. Doing so, may result in the work being done sequentially rather than in parallel. However, it should be OK to use them on the collection before you apply the AsParallel extension method.
amShekar42 reputationPosted May 6, 2013, 5:48 AM EDT
I have developed one console application there the EnumerateFiles().Take(intval) working as expected i.e only intVal no of file its extracting from the folder but when i merged this changes in existed windows service i.e replace getfiles with Enumeratefiles throught the Windows services application the seems .Take(intval) not working i.e instead of intVal no of file the service (my enumeratefiles code with take() ) fetching the all file that contains in folder what could be the reason.
NOTE: This is my actual requirement where iam planning to customise getfiles. Actually my application (window services) is multithreaded application having several getfiles() methods
VulpesRank #55 · 29.2K reputationPosted May 6, 2013, 7:05 AM EDT
I assume you're testing it on the same directory as you used in the Console application?
You could try using TakeWhile or Skip to see if they behave peculiarly as well.