locked
storing items in a collection in a string array RRS feed

  • Question

  • User1057623887 posted

     I have a string array called m_DirFileList and a collection called myFileCollection. I'm trying to loop through the items in the collection and store each one in the string array. It's not working though. This is what I'm trying to do:

     Dim myFileCollection As Collection = clsFTPClientClass.GetFileList(fileFilter, True)
            intItems = clsFTPClientClass.GetFileList(fileFilter, True).Count()
    
    
            'Debug.Print("count=" & intItems)
            'MessageBox.Show(intItems)
    
            ' Loop through all items in the collection
            For i = 0 To intItems - 1
    
                m_DirFileList = myFileCollection.Item(i)
    
            Next

     
    What am I doing wrong? Thanks

     

    Wednesday, September 2, 2009 11:24 AM

Answers

All replies

  • User-1360095595 posted

    Don't know if this helps, but if you use a List<T> collection instead, you can make use of the ToArray method to return an array of items in one call.

    Refer: http://msdn.microsoft.com/en-us/library/x303t819.aspx

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, September 2, 2009 12:02 PM
  • User1057623887 posted

     This probably is a better idea. I will have to look into using a generic list instead of using the Microsoft.VisualBasic namespace, which I believe is outdated. I'm working with outdated code though so I was trying not to alter it more than necessary. My project is v6/vb.net hybrid.

    Friday, September 4, 2009 11:32 AM