public bool isExeDllFile(string sFileName)
{
bool xx=false; //default the "sFileName" is not a .exe or .dll file;
FileStream fs = new FileStream(sFileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
string bx="";
byte buffer;
try
{
buffer=r.ReadByte();
bx=buffer.ToString();
buffer=r.ReadByte();
bx=bx+buffer.ToString();
}
catch
{
}
r.Close();
fs.Close();
if (bx=="7790" || bx=="8297" || bx=="8075" )//7790:exe 8297:rar 8075:pk
{
xx=true;
}
return xx;
}
dll:MZ
exe:MZ
rar:Rar
zip:PK
{
bool xx=false; //default the "sFileName" is not a .exe or .dll file;
FileStream fs = new FileStream(sFileName, FileMode.Open, FileAccess.Read);
BinaryReader r = new BinaryReader(fs);
string bx="";
byte buffer;
try
{
buffer=r.ReadByte();
bx=buffer.ToString();
buffer=r.ReadByte();
bx=bx+buffer.ToString();
}
catch
{
}
r.Close();
fs.Close();
if (bx=="7790" || bx=="8297" || bx=="8075" )//7790:exe 8297:rar 8075:pk
{
xx=true;
}
return xx;
}
dll:MZ
exe:MZ
rar:Rar
zip:PK