Extracting files and directories from a provided list into separate lists This code gets a list of all files and directories from a specific location. Thes code below works.

List&lt;string&gt; FullList = new List&lt;string&gt;(LoadFiles("patch.txt"));
List&lt;string&gt; ShortCatalogList = new List&lt;string&gt;();
List&lt;string&gt; ShortFileList = new List&lt;string&gt;();


            for (int i = 0; i &lt; FullList.Count; i++)
                {

                    if (System.IO.Path.HasExtension(FullList[i]))
                    {
                    ShortFileList.Add(FullList[i]);
                    }


                    if (!System.IO.Path.HasExtension(FullList[i]))
                    {
                        ShortCatalogList.Add(FullList[i]);

                    if (Directory.GetFiles(FullList[i]).Length &gt; 0)
                        {                           
                            string[] subFile = Directory.GetFiles(FullList[i]);
                                for (int io = 0; io &lt; subFile.Length; io++)
                                    {
                                        ShortFileList.Add(subFile[io]);
                                    }
                        }

                    if (Directory.GetDirectories(FullList[i]).Length &gt; 0)
                     {
                            string[] subFolder = Directory.GetDirectories(FullList[i]);

                            for (int io = 0; io &lt; subFolder.Length; io++)
                            {
                                FullList.Add(subFolder[io]);
                            }                   
                   }
                  }
                 }


I know that I need to protect from permission problem.
Most is said about this code in the other answer, but there is a simplification which can be used to beautify this code a lot.  

The Directory class has two methods which returns IEnumerable&lt;string&gt; namely EnumerateFiles() and EnumerateDirectories().  

The results of the calls to this methods can be used to call AddRange() on the ShortFileList and FullList.  

Like so  

List&lt;string&gt; fullList = new List&lt;string&gt;(LoadFiles("patch.txt"));
List&lt;string&gt; shortCatalogList = new List&lt;string&gt;();
List&lt;string&gt; shortFileList = new List&lt;string&gt;();


for (int i = 0; i &lt; fullList.Count; i++)
{

    if (System.IO.Path.HasExtension(fullList[i]))
    {
        shortFileList.Add(fullList[i]);
        continue;
    }

    shortCatalogList.Add(fullList[i]);

    var files = Directory.EnumerateFiles(fullList[i]);
    shortFileList.AddRange(files);

    var directories = Directory.EnumerateDirectories(fullList[i]);
    fullList.AddRange(directories);

}