This program writes out all the files in the current directory level to a text file, outputs an array of sub-directories at the current level, then repeats this process until there are no more sub-directories to search.  The code below take 50 seconds to run.I was hoping I could get any pointers on the code in general (I'm very new to C#) and also any suggestions for improving the runtime.using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.IO;namespace ComputerFileOutput{    class Program    {        // Prints a string array of files located in specified path        static void filesArray(string path)        {                string[] array = Directory.GetFiles(path);                addFilesToTextFile(array);        }        //Appends files to .txt document        static void addFilesToTextFile(string[] fileArray)        {            //Append fileArray to current .txt document            using (System.IO.StreamWriter file = new System.IO.StreamWriter(@C:\ComputerFiles.txt, true))            {                for (int i = 0; i < fileArray.Length; ++i)                {                    file.WriteLine(fileArray[i]);                }            }        }        //Returns a string array of directories in a specified path        static string[] getDirectories(string path)        {            return (Directory.GetDirectories(path));        }        static void Main(string[] args)        {            DateTime t1 = DateTime.Now;            string[] startUp = { ------LIST OF ALL COMPUTER FILES------ };            System.IO.File.WriteAllLines(@C:\ComputerFiles.txt, startUp);            //Get files in c directory; append to .txt file            filesArray(C:\\);            //Get array of primary directories in C drive            string[] directoryArray = getDirectories(C:\\);            //initialize subdirectory search            bool moreDirectories = true;            //Go through each directory            while (moreDirectories == true)            {                 List<string> subDirectories = new List<string>();                foreach(string directoryName in directoryArray)                {                    try                    {                        filesArray(directoryName);                        subDirectories.AddRange(getDirectories(directoryName));                    }                    catch(Exception)                    {                        Console.WriteLine(Unathorized to access directory: {0}, directoryName);                    }                }                directoryArray = subDirectories.ToArray();                if (directoryArray.Count() == 0)                {                    moreDirectories = false;                    break;                }            }            // wait for input before exiting            DateTime t2 = DateTime.Now;            Console.WriteLine(Total seconds = {0}, (t2 - t1).TotalSeconds);            Console.WriteLine(Press enter to finish);            Console.ReadLine();        }    }}
Writing out names of files on local C drive to a text document
c#;search