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?
Program Files,Program Files (x86),Users, andWindowsat the root of theC:drive would not be returned byDirectory.GetFilessince they are directories, not files.