Interesting question. What defines the last file? Is it that it was the last file added? Is it the last file by name? What about if the order is reversed?
Anyway, you don't actually need to worry about this. You can let the .NET framework take care of it for you using the
Directory
class. Here's how you would do it:
string[] files = Directory.GetFiles(@"c:\myimages", "*.jpg");
-----------------
From JSOP: The last file in the folder is the last one in the list when you do a GetFiles call. Files are stored in a "natural" order (the order the were placed/copied to the disk). The last one placed on the disk will NOT necessarily have the newest modification date, either. You can thank the guys that invented DOS for this little gem. :)