I\'m trying to filter files by extension (in particular case \".gif\") but GetFiles
method for some reason does not find any files (even if there are definitely fil
You have 3 versions of "GetFiles" method. 2 of which includes a filter option: https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles%28v=vs.110%29.aspx
The version you were using accepts a "path". Not a filter.
Option 1 Directory.GetFiles with two arguments:
var files = Directory.GetFiles(animatedgifsdirectory, "*.gif");
Option 2 DirectoryInfo.GetFiles instance method takes filter as single parameter:
var directory = new DirectoryInfo(animatedgifsdirectory);
var files = directory.GetFiles(animatedgifsdirectory, "*.gif");
Use the search pattern overload on GetFiles
:
System.IO.Directory.GetFiles(@"C:\Windows", "*.gif");