Answers for "how to check if file contains image c#"

C#
0

how to check if file contains image c#

public static readonly List<string> ImageExtensions = new List<string> { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG" };

private void button_Click(object sender, RoutedEventArgs e)
{
    var folder = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
    var files = Directory.GetFiles(folder);
    foreach(var f in files)
    {
        if (ImageExtensions.Contains(Path.GetExtension(f).ToUpperInvariant()))
        {
            // process imagek
        }
    }
}
Posted by: Guest on August-05-2020

Code answers related to "how to check if file contains image c#"

C# Answers by Framework

Browse Popular Code Answers by Language