Gute Möglichkeit, um zu überprüfen, ob die Dateierweiterung ein Bild ist oder nicht

Ich habe diese Dateitypen Filter:

    public const string Png = "PNG Portable Network Graphics (*.png)|" + "*.png";
    public const string Jpg = "JPEG File Interchange Format (*.jpg *.jpeg *jfif)|" + "*.jpg;*.jpeg;*.jfif";
    public const string Bmp = "BMP Windows Bitmap (*.bmp)|" + "*.bmp";
    public const string Tif = "TIF Tagged Imaged File Format (*.tif *.tiff)|" + "*.tif;*.tiff";
    public const string Gif = "GIF Graphics Interchange Format (*.gif)|" + "*.gif";
    public const string AllImages = "Image file|" + "*.png; *.jpg; *.jpeg; *.jfif; *.bmp;*.tif; *.tiff; *.gif";
    public const string AllFiles = "All files (*.*)" + "|*.*";

    static FilesFilters()
    {
        imagesTypes = new List<string>();
        imagesTypes.Add(Png);
        imagesTypes.Add(Jpg);
        imagesTypes.Add(Bmp);
        imagesTypes.Add(Tif);
        imagesTypes.Add(Gif);
   }

OBS: Gibt es Standardfilter in .NET oder eine kostenlose Bibliothek dafür?

Ich brauche eine statische Methode, die prüft, ob eine Zeichenfolge ein Bild ist oder nicht. Wie würden Sie das lösen?

    //ext == Path.GetExtension(yourpath)
    public static bool IsImageExtension(string ext)
    {
        return (ext == ".bmp" || .... etc etc...)
    }

Lösung mit Jeroen Vannevel EndsWith. Ich denke es ist ok.

    public static bool IsImageExtension(string ext)
    {
        return imagesTypes.Contains(ext);
    }

Antworten auf die Frage(5)

Ihre Antwort auf die Frage