• I'm using version 2008 R2. In my SSIS package I have a for each loop container that reads multiple xml files and inserts data into sql tables. That works fine. The last step in the for each loop is a Script Task for archiving the XML files to another folder. So, I copied exactly the code in your example. The only change I made was the connection for the archive folder which is the Dim DestinationDirectory. One other change was instead of:

    Dim input_file As New FileInfo(Dts.Variable("FilePath").Value.ToString)

    I used:

    Dim input_file As New IO.FileInfo(Dts.Variable("FilePath").Value.ToString)

    Without making that change I was getting the error: "Type InfoFile is not defined"

    Now I'm getting this error during execution:

    Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The path is not of a legal form.

    at System.IO.Path.NormalizePathFast(String path, Boolean fullCheck)

    at System.IO.FileInfo..ctor(String fileName)

    at ST_b1430fd9112f48ef96919934e7029f42.vbproj.ScriptMain.Main()

    --- End of inner exception stack trace ---

    at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)

    at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

    at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)

    at Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTATaskScriptingEngine.ExecuteScript()

    Here is my script:

    Imports System

    Imports System.Data

    Imports System.Math

    Imports Microsoft.SqlServer.Dts.Runtime

    <System.AddIn.AddIn("ScriptMain", Version:="1.0", Publisher:="", Description:="")> _

    <System.CLSCompliantAttribute(False)> _

    Partial Public Class ScriptMain

    Inherits Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

    Enum ScriptResults

    Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success

    Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure

    End Enum

    Public Sub Main()

    Dim DestinationDirectory As String = "T:\Developers\Ron.Dore\CyberCom\CyberComXMLfilesArchive\"

    Dim file_name As String() = Split(Dts.Variables("FilePath").Value.ToString, "\")

    Dim input_file As New IO.FileInfo(Dts.Variables("FilePath").Value.ToString)

    Try

    input_file.MoveTo(DestinationDirectory & file_name(2))

    Catch ex As Exception

    End Try

    End Sub

    End Class

    Thanks for your help.