Rajanikant Hawaldar
How do I list all files of a directory?

How do I list all files of a directory?

By Rajanikant Hawaldar in Python on Oct 10 2020
  • Kiran Mohanty
    Oct, 2020 13

    You can try below code.

    1. DirectoryInfo d = new DirectoryInfo(@"D:\test");//your folder path
    2. FileInfo[] Files = d.GetFiles("*.txt");
    3. string str = "";
    4. foreach(FileInfo file in Files )
    5. {
    6. str = str + ", " + file.Name;
    7. }
    8. Console.WriteLine(str);

    • 1
  • Khurram Rahim
    Oct, 2020 19

    ls -a

    • 0
  • Khurram Rahim
    Oct, 2020 16

    or ls -a for hidden files

    • 0
  • Varun Setia
    Oct, 2020 14

    In python os.listdir(), this will return everything in that directory. We can filter the records after that to only show files.

    • 0
  • Varun Setia
    Oct, 2020 14

    Directory.GetFiles([path]), this will return array of files.

    • 0

Most Popular Job Functions


MOST LIKED QUESTIONS