• I'm attempting to implement a find and replace in SSIS 2008 but I believe the code that was provided in this thread is VB not C#. I'm receiving the error : "Cannot convert type 'string' to 'System.IO.StreamReader'"

    System.IO.StreamReader reader;

    reader = (System.IO.StreamReader) Dts.Variables["User::FileSource"].Value.ToString();

    System.IO.StreamWriter writer;

    writer = (System.IO.StreamWriter) Dts.Variables["User::FileDestination"].Value.ToString();

    Without the cast to a string there are no errors with the C# code but then I'm receiving the following error when executing the script task.

    Error: 0x1 at Script Task: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidCastException: Unable to cast object of type 'System.String' to type 'System.IO.StreamReader'.

    Any assistance is greatly appreciated.

    Thank you!