我想在使用它之前检查我硬盘中的文件是否为图像。如何检查文件是否是C++中的图像类型?
我使用C++/CLI
OpenFileDialog^ openFileDialog1 = gcnew OpenFileDialog;
if (openFileDialog1->ShowDialog() == System::Windows::Forms::DialogResult::OK) {
Bitmap^ PreviewImage = gcnew Bitmap(openFileDialog1->FileName); //If File is not an image this will crash.
}
,因为我在该行评价说,如果该文件是不是会产生错误的图像,我该如何检查,如果该文件是前手的图像?
在此先感谢。
是否可以让一个例子捕获此异常?非常感谢你。 – Grego 2012-04-19 18:19:33
你在问如何使用“catch”块吗? – SLaks 2012-04-19 18:19:55
哈哈哦yeaa我的坏,我想过别的东西。 ; D这对我来说很清楚。谢谢! – Grego 2012-04-19 18:27:12