title: SSIS - File System task cannot find file path after using script task to assign variable
body: <p>In my current project I have to take an excel file of known directory but unknown name, put it into a database table and then move and rename the excel file used.</p>
  
  <p>As this is my first project I've used a few tutorials and stackoverflow pages a long the way, hence why control flow is all inside a for each loop (even if it might not be needed), but here is the control flow: </p>
  
  <p><a href="http://i.stack.imgur.com/Nepgg.png" rel="nofollow">http://i.stack.imgur.com/Nepgg.png</a></p>
  
  <p>Here is my Script task to find the excel file and assign the variables:</p>
  
  <pre><code>  public void Main()
    {
          string directoryLocation = @"I:\All\L3VA Import\"; //Change this for new directory
          int directoryLength = directoryLocation.Length;
  
          string[] filePath = Directory.GetFiles(directoryLocation, "*.xls*");
  
          int filePathLength = filePath[0].Length;
  
          Dts.Variables["myConnectionString"].Value = filePath[0];
          Dts.Variables["myFileName"].Value = filePath[0].Substring(directoryLength, filePathLength - directoryLength);
  </code></pre>
  
  <p>I then use a Data Flow task to pump the spreadsheet data into OLE DB, which doesn't work on its own, but works if the Script Task is executed first, making me believe it is correctly assigning my variables.</p>
  
  <p>My issue comes when I then try to move and rename this file using a File System Task, which seems not to find the value of these variables and encounters an error:</p>
  
  <blockquote>
    <p>Error: 0xC002F304 at File System Task, File System Task: An error occurred with >the following error message: "Could not find a part of the path.".</p>
    
    <p>Task failed: File System Task</p>
  </blockquote>
  
  <p>Here is the variable list used and file system task:
  <a href="http://i.stack.imgur.com/p6FWD.png" rel="nofollow">http://i.stack.imgur.com/p6FWD.png</a></p>