登峰之道---简约而不简单
分享阳光,分享快乐

 

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
posted on 2005-06-13 08:07  登峰  阅读(311)  评论(0编辑  收藏  举报