As always - there is more than one way to skin a cat. I've built off of tvanfosson (correct) answer, not because this is 'more' correct; but because I think it's a useful approach.
private static string getRandomFile(string path)
{
try
{
var extensions = new string[] { ".png", ".jpg", ".gif" };
var di = new DirectoryInfo(path);
return (di.GetFiles("*.*")
.Where(f => extensions.Contains(f.Extension
.ToLower()))
.OrderBy(f => Guid.NewGuid())
.First()).FullName ;
}
catch { return ""; }
}