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?
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?
Directory.GetFiles (sourceDirectory_, "*.jpg")
See the MSDN docs for this overload for more details.
You can provide the search pattern as a second parameter to GetFiles:
string[] files = Directory.GetFiles(sourceDirectory_, "*.jpg");