Reputation: 196429
I am using this to get all files in a directory:
string[] files = Directory.GetFiles(sourceDirectory_);
But is there a way to get all files that end with "jpg" in one line without doing an
if (file.endswidth("jpg")
check?
Upvotes: 3
Views: 5293
Reputation: 8992
You can provide the search pattern as a second parameter to GetFiles:
string[] files = Directory.GetFiles(sourceDirectory_, "*.jpg");
Upvotes: 4
Reputation: 1499770
Directory.GetFiles (sourceDirectory_, "*.jpg")
See the MSDN docs for this overload for more details.
Upvotes: 8