With the following code:

```
static void Main(string[] args)
    {
        JObject fileSystemTree = CreateFileSystemJsonTree("C:/DirectoryTree");
        Console.WriteLine(fileSystemTree);
        Console.WriteLine("------");
        //
        //  Write it out to a file
        //
        System.IO.File.WriteAllText(@"C:\jsontree.txt", fileSystemTree.ToString());
        Console.ReadLine();
    }
    static JObject joNew = new JObject();
    static JObject CreateFileSystemJsonTree(string source)
    {
        //
        //  Build a list of all the IPs
        //
        //Console.WriteLine(source);
        using (var poiDbContext = new poiDbEntities())
        {
            DirectoryInfo di = new DirectoryInfo(source);
                {
                    joNew = new JObject(
                        new JProperty(di.Name, new JArray(Directory.GetDirectories(source).Select(d => CreateFileSystemJsonTree(d)))),
                        new JProperty("files", new JArray(di.GetFiles().Select(fi => new JObject(new JProperty(fi.Name, GetText(fi.Name)))))));
                }
                Console.WriteLine(joNew);
        }
        return joNew;
    }
    public static string GetText(string fiName)
    {
        using (var poiDbContext = new poiDbEntities())
        {
            string indexNameBody = fiName.Substring(0, fiName.LastIndexOf('.'));
            var indexResult = "test";  // dummied up for use by evaluators 
            return indexResult.Trim();
        }
    }

```

I am trying to create a filetree from a system directory using recursion. I have this working with XML but would prefer a JSON tree. The problem is that the txt files appear, not withing the Parent's [], which represents the lowest folder, but instead being added as JsonProperties with the text name I have added as "files"(which I don't want). Plus the "files" are generated even if there are no files, such as in an empty folder. The system generated snippet is followed by the a possible desired snippet.

```
"Sports": [
        {
          "NBA": [],
          "files": []  // Undesirable--The folder is empty`` 
        },``

```

The two snippets:

```
{  
      "Politics": [  
        {  
          "PresCandidates": [  
            {  
              "Republican": [],   // Notice the files are not in array   within the [] of the Republican    
              "files": [    
                {  
                  "carson_ben_s.txt": "Ben Carson"  
                },  
                {  
                  "trump_donald_j.txt": "Donald Trump"  
                },  
                {
                  "walker_scott_k.txt": "Scott Walker"  
                }  
              ]  
            }  
          ]  
        }  
      ],  
      "Politics": [  // The desired format
        {  
          "PresCandidates": [  
            {  
              "Republican": [  
                                {  
                                    "carson_ben_s.txt": "Ben Carson"  
                                },  
                                {  
                                    "trump_donald_j.txt": "Donald Trump"  
                                },  
                                {  
                                    "walker_scott_k.txt": "Scott Walker"  
                                }  
                            ],  

```

{