I am getting an error in C# Visual Studio and there doesn’t seem to be any clear-to-the-point answer to this question online.
When I want to add mscorlib, I get this error message:
A reference to ‘mscorlib’ could not be added. This component is automatically referenced by the project system and cannot be referenced directly.
but .EnumerateFiles() needs that library.
Why would this message show when one want to add a specific reference?

MSDN is good place to solve such mysteries –
DirectoryInfo.EnumerateFilesclearly shows that it is supported by 4.0 and 4.5 versions of .NET.You are trying to link against 2.0 (or maybe something like 3.0/3.5) and do not have such function. Your error clearly says that you can’t add the assembly to the project since it is always referenced automatically for correct version of runtime.
To be able to use the new
EnumerateFile, you need to build against 4.0+, or write code without that function.