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