誰かが間違いを見つけるのを手伝ってくれることに感謝します。リストのアイテムをコンソールに出力しました。各アイテムを強調表示するには、カーソルを下に移動する必要があります。次のように試しました。
foreach (FileSystemInfo fsi in files)
Console.WriteLine(fsi); //printing the "files" list
Console.SetCursorPosition(0, 0); //setting initial place of cursor
while (Console.ReadKey(true).Key != ConsoleKey.Escape) //untill i press escape
{
switch (Console.ReadKey(true).Key)
{
case ConsoleKey.DownArrow: //for Down key
foreach (FileSystemInfo fsi in files)
{
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.Green;
// Here's the problem, the cursor goes to the end of the list,
// not moving through each item:
Console.SetCursorPosition(0, files.IndexOf(fsi));
}
break;
}
}
Console.ReadKey();
どんな助けにも感謝します!前もって感謝します!