确定文件是否为有效的图像格式 [英] Determine whether a file is a valid image format

查看:96
本文介绍了确定文件是否为有效的图像格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用C#在Windows中的一个小型项目中工作,我需要确定文件(不带任何扩展名)是否是有效的图像文件.是否有任何内置的库函数,以便简化工作?

I am working for a small project in windows using C# where I need to determine whether a file (without any extension) is a valid image file or not. Is there any inbuilt library function so that I can simplify the task of doing it?

推荐答案

使用

Image.FromFile(path); 

如果path的文件不是有效的图像,则抛出该异常.

It throws if the file of path is not a valid image.

这篇关于确定文件是否为有效的图像格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆