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. Using GetFiles

Using GetFiles

Scheduled Pinned Locked Moved C#
question
2 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.
  • M Offline
    M Offline
    MKlucher
    wrote on last edited by
    #1

    I want to retrive all the files in a directory of certian types (.bmp, .jpg, .gif) etc etc. But I seem to only be able to pass in a single filer to the functiond filesInDirectory = Directory.GetFiles(PictureDirectory, "*.jpg"); Works fine but: filesInDirectory = Directory.GetFiles(PictureDirectory, "*.jpg;*.bmp"); Does not work correctly at all, Is there any way to do this, without calling multiple times and joining arrays? Also it seems to just return them in alphabetical order, is there anyway to return them in the way they are sorted/being viewed in Explorer? Thanks!

    V 1 Reply Last reply
    0
    • M MKlucher

      I want to retrive all the files in a directory of certian types (.bmp, .jpg, .gif) etc etc. But I seem to only be able to pass in a single filer to the functiond filesInDirectory = Directory.GetFiles(PictureDirectory, "*.jpg"); Works fine but: filesInDirectory = Directory.GetFiles(PictureDirectory, "*.jpg;*.bmp"); Does not work correctly at all, Is there any way to do this, without calling multiple times and joining arrays? Also it seems to just return them in alphabetical order, is there anyway to return them in the way they are sorted/being viewed in Explorer? Thanks!

      V Offline
      V Offline
      Vikram A Punathambekar
      wrote on last edited by
      #2

      I googled a bit and tried using ; and | as separators, but they don't work. In fact, using | as a filter separator throws an exception. I suppose the best bet is to call the method multiple times and club the results together. Kluch wrote: Also it seems to just return them in alphabetical order, is there anyway to return them in the way they are sorted/being viewed in Explorer? Are you saying that if the contents of folder Foo appear sorted by name in Explorer, your app should offer them sorted by name; and if the contents of folder Foo appear sorted by date created in Explorer, your app should offer them sorted by date created? AFAIK, there's no way to do this. Cheers, Vikram.


      http://www.geocities.com/vpunathambekar

      Google talk: binarybandit

      After all is said and done, much is said and little is done.

      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