title: C# Script Task To Rename a file based on a wild card search
body: <p>I am trying to create a C# Script Task to rename a pair of files I receive everyday that has an appended 16 digit time stamp at the end. The files like something like this "Cartons_2018091014000000"</p>
  
  <p>I am pretty low experience when it comes to C# so please forgive my attempt at a logical construction.</p>
  
  <p>Here's what I was thinking would work, but am getting some very non descriptive errors.</p>
  
  <pre><code>        public void Main()
      {
          String txtfile = null;
          String[] fileEntries = Directory.GetFiles(@"\\test-file-server-name\Scripts\", "Cartons_*");
  
              foreach (string filename in fileEntries)
          {
              if(filename.Contains("Cartons"))
              {
                  txtfile = filename;
                  System.IO.File.Move(txtfile, "Cartons.csv");
              }
          }    
          // TODO: Add your code here
  
          Dts.TaskResult = (int)ScriptResults.Success;
      }
  </code></pre>
  
  <p>Any thoughts or suggestions? Or maybe a better / more elegant way to do this in SSIS? I was thinking I would use a ForLoop container, but the reason I don't think it will work is because the file names change every hour due to that timestamp appending.</p>