I know that this thread exists, but the answer is not completely correct.
I have a folder and want to get all file names which have an extension .DOC. But there are also files in the directory with the extension .DOCX which I don't want in the returned value.
But by using string[] files = System.IO.Directory.GetFiles(path, "*.DOC") I get both of them while I am searching for only the .DOC files.
Thus, currently I am reading both and using an if statement to filter the filenames again:
foreach (var originfile in files)
{
if (Path.GetExtension(originfile).ToUpper() == ".DOC")
{
...
}
}
I wanted to ask if there is any possibility to get only the .DOC files with System.IO.Directory.GetFiles. The documentation states that it is not possible to use regular expressions.