Results 1 to 3 of 3

Thread: [RESOLVED] Remove Certain list items

Threaded View

  1. #1

    Thread Starter
    Lively Member elmnas's Avatar
    Join Date
    Jul 2009
    Posts
    127

    Resolved [RESOLVED] Remove Certain list items

    Hello people,


    I have made a code that generates all paths from folders and sub folders in a certain path.

    the list contains like 6000 different items.

    I want to remove all list items that contains "junk" or "junk2" the phrases are always the last phrase in the path for the list item example:
    C:\X\blablablal\junk
    C:\X\blablablal\awdasdasd\junk2
    C:\X\adjassdasd\junk



    Code:
       Dim listofstrings As New List(Of String)
    
    
            ' For Each d In Directory.EnumerateDirectories("X:\1 Övriga kunder\Arkiv\Originalfiler", "*.*", SearchOption.AllDirectories)
            For Each d In Directory.EnumerateDirectories("C:\X\", "*.*", SearchOption.AllDirectories)
                Dim myPath = ((d.ToString()))
                listofstrings.Add(myPath)
                'Console.WriteLine(myPath)
            Next
    
       For Each Pitem In listofstrings
    
                If Pitem.Contains("junk" or "junk2") Then
    
                    Pitem.Remove()
    
                End If
            Next
    
    
        End Sub
    Could someone help me with a code that works?

    my loop doesn't work

    Thank you in advance
    Last edited by elmnas; Dec 7th, 2015 at 05:28 AM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width