We pay for user submitted tutorials and articles that we publish. Anyone can send in a contributionLearn More
Here is something neat I found out.
Say you are writing an application and one of the requirements is to allow File System search. You could always start using loops and such. I thought to myself why not do it in LINQ? I played around with it and in fact it is not so hard.
Lets see how it is done. Here is method that allows finding a specific file name in side a directory.
Basically we Query the FileInfo which is returned from the GetFiles() method and compare the file name.
Here is another example for using a Query for the file extension, it is very much the same except for the condition:
Of course this is only usable for one directory but you can easily expand it and make it recursive. I bet you are as lazy as I am so here is something
Nice isn’t it? If I have a bug Please Comment.
Copyright © 2012 Dev102.com
Breeze : Designed by Amit Raz and Nitzan Kupererd