How does one search for file extension instead of file name?

I have this simple Line of Code that retrieves a texture from a folder.

var www = new WWW("file://" + folder + "/pic001.png");

It finds pic001.png fine. How do I make it find any file with the .png file extension?
or what ever extension is needed.

I thought it would be like below but it fails to find the image “.png”.

var www = new WWW("file://" + folder + ".png");

Thanks, Tim.

You can get the list of files in a directory using DirectoryInfo

Then you can find the specific file that you want and pass that as argument to your WWW.

For more info on how to find files by extension, check questions below: