This is to do a picture to browse the time to think of the problem, think in the picture when there are many different formats of the file needs to be opened, so you have to let the program support this function,
If we just open a type of picture, we might write it like this.
New ArrayList (); // Store Pictures string [] files; // folders that need to be opened files = Directory. GetFiles (Path,"*jpg"foreachstring in files) { new FileInfo (item); List. ADD (info); } return list;
When a variety of times we can put him into a loop to traverse, on the code
PublicArrayList getimages () {string[] ext = {"*png","*jpg","*bmp"};//the picture format to openArrayList list =NewArrayList ();//Store Pictures string[] files; for(inti =0; I <3; i++) {Files=Directory. GetFiles (Path,ext[i]); foreach(stringIteminchfiles) {FileInfo Info=NewFileInfo (item); List. ADD (info); } } returnlist; }
How to get multiple files with different suffixes during disk traversal