title: SSIS Script Task Check if a folder is empty
body: <p>Within a SSIS Script Task, I have the below code that checks if a folder is empty.  I then want to pass if it is or not into the variable 'Dim_File_Count' and use a Precedence constraint to move onto the next task if successful.  However my code keeps stating the folder is empty, even when it's not:</p>
  
  <pre><code>public void Main()
  {
      //string FolderName = Dts.Variables["User::Tech_Dim"].Value.ToString();
  
      if (File.Exists(Dts.Variables["User::Tech_Dim"].Value.ToString())==false)
      {
          Dts.Variables["User::Dim_File_Count"].Value = 0;
          MessageBox.Show("folder empty");
      }
      else
      {
          Dts.Variables["User::Dim_File_Count"].Value = 1;
          MessageBox.Show("folder is not empty");
      }
  
  
  
      Dts.TaskResult = (int)ScriptResults.Success;
  }
  </code></pre>