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();
        }


    }
}

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.

commented: Thank you +2
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.