Merging three 1-dimension arrays into one.

Hello friends,

I have three arrays (1-dimension) by name ftplist-1, ftplist-2, ftplist-3.

I want to combine those three into ONE by name ftplist.

Can any one help me how can we do that either in VB.net or C# in SSIS. Here I did and its giving error..."Error: Object reference not set to an instance of an object."

    Dim ftp_fileList1 As String() = Nothing
            Dim ftp_fileList2 As String() = Nothing
            Dim ftp_fileList3 As String() = Nothing
            Dim ftp_fileList As String() = New String(ftp_fileList1.Length + ftp_fileList2.Length - 1 + ftp_fileList3.Length - 1) {}                

           strFile = "L:\Ftp_Files_List.txt"

            ftp_fileList1.CopyTo(ftp_fileList, 0)
            ftp_fileList2.CopyTo(ftp_fileList, ftp_fileList1.Length)
            ftp_fileList3.CopyTo(ftp_fileList, ftp_fileList2.Length)

             For Each LocalFile As String In ftp_fileList

             File.AppendAllText(strFile, LocalFile & vbCrLf)

              Next

Where am I doing wrong? Can anyone help? Thanks in advance.


October 30th, 2013 3:23am

The arrays has no values and hence the CopyTo is failing.

From where you are populating the 3 arrays?

Free Windows Admin Tool Kit Click here and download it now
October 30th, 2013 3:27am

Hi

You have not in instantiation your arrays, for example ftp_fileList2 , ftp_fileList3  and ftp_fileList1 .

Try changing the code as this:

   Dim arryLenght As Integer = 0
        Dim ftp_fileList1 As String() = New String() {}
        Dim ftp_fileList2 As String() = New String() {}
        Dim ftp_fileList3 As String() = New String() {}
        Dim ftp_fileList As String() = New String() {}
      

        ftp_fileList = New String(ftp_fileList1.Length + ftp_fileList2.Length + ftp_fileList3.Length - 1) {}

        ftp_fileList1.CopyTo(ftp_fileList, 0)
        ftp_fileList2.CopyTo(ftp_fileList, ftp_fileList2.Length)
        ftp_fileList3.CopyTo(ftp_fileList, ftp_fileList3.Length)

October 30th, 2013 3:39am

Thank you guys for your valuble time.

Harsh ji... no luck even I changed the code as per your instructions. Same error coming. In the mean while I am trying to do the debugging in break points as per the link you send and I shall post once I am able to get the errors at break point level.  

Free Windows Admin Tool Kit Click here and download it now
October 30th, 2013 3:49am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics