I do not know the feasibility of doing in lambda or linq my expression

0

I have these two lists:

List<string> dirZipDireto = ConfigurationManager.AppSettings["Dir_Zip_Direto"].Split(';').ToList();
List<string> arquivos = Directory.GetFiles(caminhoCommiter, "*", SearchOption.AllDirectories).ToList();

To minimize lines of code and give more code beauty and consistency, I believe I can improve this and avoid some foreach. What I want:

I would like to load the arquivos list with files, except those that exist in the dirZipDireto directory list. So the code for arquivos can be minimized and in a single expression?

    
asked by anonymous 03.03.2016 / 21:11

1 answer

2

What about?

var arquivosFiltrados = (from arquivo in arquivos
                         where !(from dirEvitar in dirZipDireto
                                 where arquivo.Contains(dirEvitar)
                                 select dirEvitar).Any()
                         select arquivo).ToList();
    
03.03.2016 / 21:19