Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. having filefilter problem

having filefilter problem

Scheduled Pinned Locked Moved C#
helpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Pyro Joe
    wrote on last edited by
    #1

    hi, when I use this bit of code to get the number of files with the extensions ".mp3, .wma, and .wav" as follows: int number_of_files = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.mp3;*.wma;*.wav", SearchOption.AllDirectories).GetLength(0); it doesn't return any results. (the number_of_files integer is still 0). I tried this using only *.mp3 and got some results. Why doesn't this work? Am I not supposed to use the semi-colon symbol? IF so which one am I supposed to use? Thanks for your help.

    S 1 Reply Last reply
    0
    • P Pyro Joe

      hi, when I use this bit of code to get the number of files with the extensions ".mp3, .wma, and .wav" as follows: int number_of_files = Directory.GetFiles(folderBrowserDialog1.SelectedPath, "*.mp3;*.wma;*.wav", SearchOption.AllDirectories).GetLength(0); it doesn't return any results. (the number_of_files integer is still 0). I tried this using only *.mp3 and got some results. Why doesn't this work? Am I not supposed to use the semi-colon symbol? IF so which one am I supposed to use? Thanks for your help.

      S Offline
      S Offline
      sgatto159
      wrote on last edited by
      #2

      I think second parameter is a simple pattern, not a regexp. You can't do things like *.mp3|*.mpg

      P 1 Reply Last reply
      0
      • S sgatto159

        I think second parameter is a simple pattern, not a regexp. You can't do things like *.mp3|*.mpg

        P Offline
        P Offline
        Pyro Joe
        wrote on last edited by
        #3

        so what can I do? I'd prefer to not have to have multiple lines as when I eventually have to add found file strings to an array, it'll be somewhat confusin and if there's another way, needless. any ideas? thanks again.

        S 1 Reply Last reply
        0
        • P Pyro Joe

          so what can I do? I'd prefer to not have to have multiple lines as when I eventually have to add found file strings to an array, it'll be somewhat confusin and if there's another way, needless. any ideas? thanks again.

          S Offline
          S Offline
          sgatto159
          wrote on last edited by
          #4

          Write a method like this: public void findFiles(string where, bool recurse, params string[] what){ /*...*/ } so you can invoke without arrays: findFiles("c:\\", true, "*.mp3", "*.avi"); findFiles("d:\\", false, "*.mp3"); and so on. hope this helps

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups