Results 1 to 7 of 7

Thread: [RESOLVED] permeate case

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    9

    Resolved [RESOLVED] permeate case

    So i'm still working on my music sorter, and i've encountered another slight issue with the case of extensions.
    I'm using

    Code:
     My.Computer.FileSystem.GetFiles(PATH, FileIO.SearchOption.SearchAllSubDirectories, FORMATS)
    to get at the files, but since this is done with a string for the formats, i need to be able to get each permutation of the case of each format

    so if it's *.mp3, i'll also get *.Mp3, *.mP3, and *.MP3

    I've tried any number of things, but what i would like to do is accumulate to a variable so i can return a great big string containing all of the various case permutations

    Code:
           For Each element In inputArray
                For Each i In element
                 'what do i do here :(
                Next
                MessageBox.Show(element)
    
            Next

    and i'd still like to know how to embed the dll in my exe

  2. #2
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: permeate case

    Are you sure the format (wildcard pattern actually) is case-sensitive? I can't imagine that. If it is, you can always use System.IO.Directory.GetFiles instead, which I'm pretty sure is not case-sensitive.

    Obviously if the pattern is not case-sensitive, then mp3, Mp3, mP3, etc are all considered equal and you don't need to use them all, you just use one of them.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    9

    Re: permeate case

    Yeah, I've put it to the test myself, but because its comparing part of the file name to string data, it wont pull it if the file itself doesn't match the string with case as well. it would be great if it had an option to ignore case :P

    and i get the same results...or lack of results with System.IO.Directory.GetFiles



    thanks for trying though!

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    9

    Re: permeate case

    any other suggestions or ideas. i've managed to get the inversion cases and the all upper and all lower cases this way with code like this

    Code:
            For Each ext In inputArray
    
                ext = ext.ToUpper & ext.ToLower
    
                For Each i In ext
                    If acounter Mod 2 = 0 Then
                        a += i.ToString.ToUpper
                    Else
                        a += i.ToString.ToLower
                    End If
                    acounter += 1
    
    
                    If bcounter Mod 2 = 0 Then
                        b += i.ToString.ToLower
                    Else
                        b += i.ToString.ToUpper
    
                    End If
                    bcounter += 1
                Next
                ext += a + b
                MessageBox.Show(ext)
            Next
    but i can't for the life of me think of a good way to get the case pairs like ABc and aBC

  5. #5
    PowerPoster
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,070

    Re: permeate case

    I still stand by my first post: the pattern argument of the GetFiles function is not case-sensitive.

    Proof:


    I've got 5 text files, each with a ".txt" extension in different casings. You can see my code in action: it uses System.IO.Directory.GetFiles with a "*.txt" search pattern, and it finds all 5 files.

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: permeate case

    The My.Computer.FileSystem.GetFiles isn't case-sensitive either. Internally, the My.Computer.FileSystem.GetFiles and System.IO.Directory.GetFiles use the same class and methods (though I'm not 100% sure).
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  7. #7

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    9

    Re: permeate case

    ahhhh, i see. in my get tag function i was also comparing the extension of the file sent, to a format variable, which is built from a textbox and a few predefined formats, and that comparison was where it was breaking down.

    thank you gentlemen for all of your help. i do feel like a dunce for missing it now though :P

    Thanks ^_^

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