Windowsにおけるファイルの拡張子は、ファイルの種類を分類し、アプリケーションとの関連付けを行うためのものだ。ファイル名はユーザーが自由に変更できるため、正しい拡張子は、ファイル内のヘッダ部分などから判断するしかない。画像ファイルに関しては、WindowsのGDI+に組み込まれているデコーダを利用して、画像フォーマット(ファイル形式)をファイルの内容から判別することができる。 TIPS:画像を読み込むには? では、ImageCodecInfoクラス(System.Drawing.Imaging名前空間)のGetImageDecodersメソッドを使用し、次のようにしてWindowsのGDI+に組み込まれているデコーダを列挙した。 ImageCodecInfo[] decoders = ImageCodecInfo.GetImageDecoders(); ImageCodecInfoクラ