Amending code to make it list some files in a directory, rather than all
You can utilize the .Take() method in LINQ which:


  Returns a specified number of contiguous elements from the start of a sequence


Using this, your code would look as follows:

string sDir = "c:\\windows";

foreach (string f in Directory.GetFiles(sDir).Take(10))
{
    Console.WriteLine(f);
}