Directory.GetFiles allows you to specify a template for searching files:
System.IO.Directory.GetFiles(@"C:\temp\py\", "test.*")
for me returns an array of 3 matching elements. I expect an array as the directory contains test.cover, test.pyand test.pyc.
If I use the extension method First:
System.IO.Directory.GetFiles(@"C:\temp\py\", "test.*").First()
then it returns only the first result ( test.cover).
However, using the extension method Single:
System.IO.Directory.GetFiles(@"C:\temp\py\", "test.*").Single()
InvalidOperationException, " " ( , , ).
System.IO.Directory.GetFiles(@"C:\temp\py\", "step.*").Single()
step.py ( ), , step.* .