Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I'm having trouble popping elements out of a IO.FileSystemInfo array. I can't use the Remove method so I have to use the Clear method but I think I'm messing it up somewhere.

 

Here is the section of code...

 

Dim artistdir As New IO.DirectoryInfo(musicroot & "\" & dir.Name)
Dim tracksArray As IO.FileSystemInfo() = artistdir.GetFiles
Dim track As IO.FileInfo
For Each track In tracksArray
      If track.Name = "Thumbs.db" Then
             Dim trackindex = tracksArray.IndexOf(tracksArray, track.Name)
             tracksArray.Clear(tracksArray, trackindex, 1)
      ElseIf track.Name = "Desktop.ini" Then
             Dim trackindex = tracksArray.IndexOf(tracksArray, track.Name)
             tracksArray.Clear(tracksArray, trackindex, 1)
      End If
Next
If tracksArray.Length <> 0 Then.......

 

As you can see from the last line the subsequent code is dependent on these two files being removed from the array as they don't need to be considerd but even though the values match up the IndexOf method always returns -1. I've tried changing types and using the actual string instead of track.name in the IndexOf statement.

 

I've just switched from VB6 and I'm still getting me head round .NET so any help would be great.

 

Cheers!

Edited by divil
I'm getting the hang of this now... No really I am!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...