文章来源http://bbs.youkuaiyun.com/topics/340150188
/// <summary>
/// 是否是EXCEL文件
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
private bool isExcelFile(string filePath)
{
FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
byte[] b = new byte[4];
string temstr = "";
//将文件流读取的文件写入到字节数组
if (Convert.ToInt32(fs.Length) > 0)
{
fs.Read(b, 0, 4);
fs.Close();
for (int i = 0; i < b.Length; i++)
{
temstr += Convert.ToString(b[i], 16);
}
}
if (temstr.ToUpper() == "D0CF11E0")
{ return true; }
else
{ return false; }
}