|
Searching for files using LINQ
Author:
Jan Welker
|
Programming Language:
C# |
Rating:
not yet rated
|
Views:
840 |
Description:
Searching for files using LINQ
Needed Namespaces: using System.IO; using System.Linq;

|
|
| C# |
1
2
3
4
|
var files = from file in new DirectoryInfo(@"C:\").GetFiles()
where file.Name.StartsWith("_")
select file;
|
|
|
This Snippets could be interesting for you:
|
|
|
|
|
|
|
|
Comments:
(Please log in to wrtite an comment.)
|
anonymous_
wrote on:
22.09.2008
This is a nice example for LINQ, but *don't* actually use it to search for files!!! This is not DLinq, which is transformed into SQL - this actually retrieves an array of _all_ the files in a directory, with all their attributes, and then performs a search in the returned array. This is *a lot* slower if the directory contains lots of files!
|
|
|