更新时间:2023-10-11 09:07:58
如何确定文件是否可执行? [ ^ ]
如何查找文件是否为exe? [ ^ ]
检查文件是否是可执行文件。 [ ^ ]
How to determine if a file is executable?[^]
How to find if a file is an exe?[^]
Check if a file is an executable.[^]
尝试这个选项对我有用...
Try this option it worked for me...
public bool IsFileUploadExecutable(string strfilePath)
{
var twoBytes = new byte[2];
using(var stream = File.Open(strfilePath, FileMode.Open))
{
stream.Read(twoBytes, 0, 2);
}
return Encoding.UTF8.GetString(twoBytes) == "MZ";
}
http://***.com/questions/58510/using- net-how-you-you-the-mime-type-of-a-file-on-the-file-signature [ ^ ]