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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 6, 2013, 11:05 AM
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.
amShekarPosted May 6, 2013, 9:48 AM
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
VulpesPosted May 3, 2013, 8:58 AM
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.
amShekarPosted May 3, 2013, 5:26 AM
i.e i have one folder containing 50000 files every thread calling 1500 files
will it achieve my requirement
VulpesPosted Apr 2, 2013, 8:12 AM
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.
amShekarPosted Apr 2, 2013, 7:44 AM
But in My.computer.Filesystem the enumeratefiles didnt find there i can find getfiles only
how can we tackle
thanks in advance vuples
VulpesPosted Apr 2, 2013, 6:54 AM
amShekarPosted Apr 2, 2013, 2:52 AM
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 :)
VulpesPosted Apr 1, 2013, 3:54 PM
amShekarPosted Apr 1, 2013, 3:32 PM
For older frameworks ?
VulpesPosted Apr 1, 2013, 1:39 PM
' ....