-3

I've got a question. I want to save all TXT Files of a directory in an Array. But how should I do it ?

System.IO.File[] files = System.IO.File(DESKTOP_PATH);

(...) doesn't work. Can anyone help me? How do I search for ONLY TXT files ?

Greetings from the US

ASh
  • 34,632
  • 9
  • 60
  • 82

1 Answers1

-1

string[] files = Directory.GetFiles(Path);

Funny Bunny
  • 124
  • 8
  • 1
    `string[] files = Directory.GetFiles(path, "*.txt");` is the answer in a [duplicate](https://stackoverflow.com/questions/3152157/find-a-file-with-a-certain-extension-in-folder) – Rufus L Mar 26 '21 at 19:44
  • The question literally has that part in all caps: *"How do I search for ONLY TXT files?"* The answer you presented is a single line of unformatted code, with no additional explanation as to how to get just files of a certain extension or type. Code-only answers are generally considered low quality, and since it also doesn't answer the question, I think it's worthy of a down-vote. You're free to take the feedback and improve the answer, though! – Rufus L Mar 30 '21 at 18:31