This project has moved and is read-only. For the latest updates, please go here.

DirectoryCatalog - finding files in subdirectories

Feb 26, 2010 at 10:43 PM

Pretty new to MEF.  We're migrating our product from System.AddIn to MEF.  I'm loving the simplicity of MEF. 

One question/observation.  System.AddIn's discovery process allowed each AddIn to be in its own subdirectory.  This is nice if you have many addins that each have many files.

As such, I was looking for this in DirectoryCatalog.  AFAIK you can't do this with just the search pattern.  I added a SearchOption parameter to the constructor, and altered the DirectoryCatalog.GetFiles code to pass that along to Directory.GetFiles.

Is there already a good way to do this that I'm missing, or is this useful enough to be added in a future release?



Feb 27, 2010 at 12:21 AM

AggregateCatalog.  You can use it to roll up multiple catalogs - something like this -

AggregateCatalog agcatalog = new AggregateCatalog();
foreach (var plugindir in Directory.GetDirectories(pluginDirectory))
       DirectoryCatalog dcat = new DirectoryCatalog(plugindir);