What do you mean by "hard-coding each of the file names"? The connection string for connection manager can be dynamic and change during execution if you want. Also, if you use a script task, you can retrieve the connection string using something similar below.
Dts.Connections["MyFlatFileConnectionManager"].ConnectionString
* Example of using a File connection manager
* object rawConnection = Dts.Connections["Prices.zip"].AcquireConnection(Dts.Transaction);
* string filePath = (string)rawConnection;
* //Use the connection in some code here, then release the connection
* Dts.Connections["Prices.zip"].ReleaseConnection(rawConnection);
Yeah, connection managers take a while to get used to in the script task.
object rawConnection = Dts.Connections["Prices.zip"].AcquireConnection(Dts.Transaction);
This statement is a bit dangerous since it may throw an exception. It is essentially attempting to "connect" to the file defined by the connection manager "Prices.zip". The connection is then stored as the object rawConnection.
string filePath = (string)rawConnection;
This statement returns the file path from the "Prices.zip" connection manager.
Dts.Connections["Prices.zip"].ReleaseConnection(rawConnection);
The last statement releases the connection to the file specified by the "Prices.zip" connection manager.
If you just want to check if the file exists, use the statement below in conjunction with the File.Exists method.
Dts.Connections["MyFlatFileConnectionManager"].ConnectionString
File.Exists
https://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
Yeah, connection managers take a while to get used to in the script task.
object rawConnection = Dts.Connections["Prices.zip"].AcquireConnection(Dts.Transaction);
This statement is a bit dangerous since it may throw an exception. It is essentially attempting to "connect" to the file defined by the connection manager "Prices.zip". The connection is then stored as the object rawConnection.
string filePath = (string)rawConnection;
This statement returns the file path from the "Prices.zip" connection manager.
Dts.Connections["Prices.zip"].ReleaseConnection(rawConnection);
The last statement releases the connection to the file specified by the "Prices.zip" connection manager.
If you just want to check if the file exists, use the statement below in conjunction with the File.Exists method.
Dts.Connections["MyFlatFileConnectionManager"].ConnectionString
File.Exists
https://msdn.microsoft.com/en-us/library/system.io.file.exists%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396
- Marked as answer by pdconway 14 hours 59 minutes ago