/// <summary>
/// 判断字节数组是否为空,空返回false 不为空true
/// </summary>
/// <param name="object1"></param>
/// <returns>判断字节数组object1是否为空,空返回false 不为空true</returns>
public static bool BytesIsNull(object object1)
{
bool flag = false;
// System.Object obj = ...; // 获取对象的方式
if (object1 is System.DBNull)
{
// 如果obj是System.DBNull的实例,那么执行这里的代码
return flag;
}
else
{
// 如果obj不是System.DBNull的实例,那么执行这里的代码
string obj = object1.ToString();
if (!string.IsNullOrEmpty(obj))
{
byte[] imageBytes = (byte[])object1;
using (MemoryStream ms = new MemoryStream(imageBytes))
{
if (ms.Length == 0)
{
//Console.WriteLine("LONGBLOB数据为空");
return flag;
}
else
{
// Console.WriteLine("LONGBLOB数据不为空");
return true;
}
}
}
}
return flag;
}