【发布时间】:2018-05-04 09:01:32
【问题描述】:
我正在尝试不使用try-catch 来实现这个目标
这是我的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
namespace ConsoleApplication3
{
class Program
{
static void Main(string[] args)
{
Bitmap imagePattern = new Bitmap(@"test.jpg");
Console.Read();
}
}
}
但如果 test.jpg 损坏,那么 C# 会显示错误,所以我的问题是:C# 中是否有类似 IsValidImage() 的函数?
谢谢!
【问题讨论】:
-
希望这可能会有所帮助stackoverflow.com/a/210667/3583859
-
这个问题不是重复的,因为它是关于内存位图结构的。它与从文件加载的位图无关,需要验证测试。