Hi here is my code,can someone help to edit the directory.getfile(),so i could output all files in c:\ Windows ?

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LogicalDrives
{
    class Program
    {

        public static void GetLogicalDrives()
        {
            string[] drives = System.IO.Directory.GetLogicalDrives();
            foreach (string str in drives)
            {
                System.Console.WriteLine(str);
            }
        }
        public static void GetDirectories()
        {
            string[] dirs = System.IO.Directory.GetDirectories(@"c:\", "W*", System.IO.SearchOption.TopDirectoryOnly);
            Console.WriteLine("The number of directories starting with W is {0}.", dirs.Length);




            foreach (string dir in dirs)
            {
                  System.Console.WriteLine(dir);

            }


        }
        static void Main(string[] args)
        {
            GetLogicalDrives();
          //  Console.ReadKey();
            GetDirectories();
            Console.ReadKey();
        }


    }
}

Edited 1 Year Ago by PulsarScript

You can use System.IO.Directory.GetFiles(DIRECTORY_NAME); which will return an array of strings that contain all the files (with full path) in that folder.

Comments
Thank you
This question has already been answered. Start a new discussion instead.