/// <summary>
/// 判断是否是图片
/// </summary>
public static bool IsPicture(Stream stream)
{
try
{
byte[] buffer = new byte[2];
stream.Read(buffer, 0, 2);
string fileClass = buffer[0].ToString() + buffer[1].ToString();
//255216是jpg;7173是gif;6677是BMP,13780是PNG;7790是exe,8297是rar
string[] fileType = { "255216", "7173", "13780", "6677" };
return fileType.Contains(fileClass);
}
catch
{
return false;
}
}