hienbt88
hienbt88

Reputation: 1369

Directory.GetFiles: Just list file in working directory

I want to get the list of files in a folder. This is my code:

var files = Directory.GetFiles("c:\\");
foreach (var f in files)
{
    Console.WriteLine(f);
}

My expectation:

C:\bootmgr
C:\BOOTNXT
C:\hiberfil.sys
C:\pagefile.sys
C:\swapfile.sys

But I got:

C:\a
C:\b
C:\c

a, b, c are files in working directory: C:\Code\test\bin\Debug

Is there a way to do it right?

Upvotes: 0

Views: 1028

Answers (1)

Nikhil Vartak
Nikhil Vartak

Reputation: 5137

Use Directory.GetDirectories method.

Upvotes: 6

Related Questions