How do I list the contents of a given directory?
We can say private string directory = @"C:\";
and what I then want is to use Console.WriteLine()
to display the contents of directory
.
However, after hours of research on this site, I still could not find an answer that worked. I have tried solutions like Directory.GetDirectories(SourcePath, "*", SearchOption.AllDirectories))
but the code failed to build. How do I fix this?
I have this at the beginning of my code:
using System;
using System.Collections.Generic;
using System.Text;
Am I missing something? What am I doing wrong? How do I fix this?