Get All Assemblies In Folder - CSharp System.Reflection

CSharp examples for System.Reflection:Assembly

Description

Get All Assemblies In Folder

Demo Code


using System.Reflection;
using System.Linq;
using System.IO;/*from w  w  w . j  a v a 2  s.  c  o  m*/
using System.Collections.Generic;

public class Main{
        public static List<Assembly> GetAllAssembliesInFolder(string folderPath, SearchOption searchOption)
        {
            var assemblyFiles = Directory
                .EnumerateFiles(folderPath, "*.*", searchOption)
                .Where(s => s.EndsWith(".dll") || s.EndsWith(".exe"));

            return assemblyFiles.Select(Assembly.LoadFile).ToList();
        }
}

Related Tutorials