I am trying to get all the .cs files in a certain path. I am doing this using
string [] files = Directory.GetFiles(path, pattern);
Where path is a valid folder path and pattern is *.cs. However this also returns AssemblyInfo.cs and i dont want that file to be included although it matches the pattern. I want to ignore all the files with the name AssemblyInfo.cs
If you still need it in an array you can do the following:
If you don’t need it as an array then you can leave off the call to
.ToArray()and that will return anIEnumerable<string>.If you’re using a version of .NET that doesn’t support Linq (i.e. a version before 3.5) then you can just skip over those parts when you iterate over the array, like so: