title: How do you get flat file name and perform a row count from multiple flat files with different columns in SSIS?
body: <p>I'm trying to get all the file names from a folder directory along with their row counts. (Also file size in bytes if possible) I am using Microsoft Visual Studio 2010 Shell. Here's what I've done so far:</p>
  
  <p>I have created a <em>Foreach Loop Container</em>, set the Enumerator to <em>Foreach File Enumerator</em> and Expressions to a variable to the folder I want to loop over. I left the Files section with <code>*.*</code> and asked to retrieve <code>Name Only</code>. I have changed the Variable Mappings to a New Variable called <code>FullFilePath</code>, Container is <code>Package</code>, Value type is <code>String</code> and Value: is blank.</p>
  
  <p>I then added a Data Flow to the Loop. Added a flat file source, row count, and OLE DB Destination. I changed the Flat file Source properties expression to the same Folder Variable in the Foreach Loop Container Expression. I added the Variable <code>RecordCount</code> to the Row Count function <em>(Int32, value 0)</em>. The OLE DB Destination creates a new table with the name OLE DB Destination.</p>
  
  <p>The next step is a Execute SQL Task that does and <code>Insert Into DBO.FileData (FileName,RowCount) Values (?,?)</code>. I set 2 parameter mappings - 1) Variable Name from the Foreach Loop Container, FullFilePath and Data Type VarChar, 2) Variable from Row Count, RecordCount and Data Type Long.</p>
  
  <p>I then have another <em>Execute SQL Task</em> that drops the table created by the data flow task. The problem is that with all the these step the Package still does not complete. It actually gets hung up and fails on the pre-execute. It says: </p>
  
  <blockquote>
    <p>Warning: Access is denied. Error: Cannot open the datafile 'FullFilePath' Error: Flat File Source failed the pre-execute phase and returned error code 0xC020200E.  </p>
  </blockquote>
  
  <p>Anything you see I could be doing wrong? Let me know if pictures would help.</p>