How to get the .jpeg files from a directory?

0

As I can only get the .jpeg files from my directory, I currently have a code that would be the following:

var directoriosE = Directory.GetFiles(@"..\..\Imagenes\Imagenes_Modal\Usuario\"+folder, "*.*", SearchOption.AllDirectories).Where(s => "jpeg".Contains(Path.GetExtension(s)));

That code should execute the obtaining of the files with the extension .jpeg, only that I have never worked with linq and I would like to know how to recover the information in format of number of the files with that extension of that directory.

Before I was doing it directly with the pure .GetFiles("Ruta") and I got it as follows archivos = archivos + directoriosE.Length; and if I gave the number of files, but gives me all the types of files in the folder now I would like to know the way to limit that.

    
asked by David 05.04.2017 в 20:13
source

1 answer

3

You could use

string folder = "...";

sting[] files = Directory.GetFiles(folder, "*.jpg", SearchOption.AllDirectories);

As you will see, "* .jpg" is defined to bring only this extension

Directory.GetFiles (String, String, SearchOption)

    
answered by 05.04.2017 / 20:46
source