Hi
I need to be able to return a list of files that meet some dynamic criteria. I've tried to do this using LINQ.
I've found that it is possible to use dynamic LINQ using the System.Linq.Dynamic namespace that it is mentioned in Scott Gu's Blog.
But I'm not sure if can be used for what I need it for.
So far I get all the files but I'm not sure where to go from there.
// Take a snapshot of the file system.
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(SourceLocation);
// This method assumes that the application has discovery permissions
// for all folders under the specified path.
IEnumerable<System.IO.FileInfo> fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories);
I now need to be able to filter these files down, using some dynamic filters that the user has created. e.g. Extension = .txt
Can anyone point me in the right direction?
Thanks. Martin.
EDIT:
The example in the Dynamic Linq library looks like this :
var query =
db.Customers.Where("City == @0 and Orders.Count >= @1", "London", 10).
OrderBy("CompanyName").
Select("New(CompanyName as Name, Phone)");
I was hoping to adapt this for the filesystem. So I can just build up a filter string and use that.