zoukankan      html  css  js  c++  java
  • 文件类型的判断

    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
  • 相关阅读:
    CCF CSP 201609-2 火车购票
    CCF CSP 201409-2 画图
    CCF CSP 201409-2 画图
    CCF CSP 201409-4 最优配餐
    CCF CSP 201409-4 最优配餐
    CCF CSP 201503-1 图像旋转
    CCF CSP 201503-1 图像旋转
    Ethical Hacking
    Ethical Hacking
    Ethical Hacking
  • 原文地址:https://www.cnblogs.com/supercode/p/173340.html
Copyright © 2011-2022 走看看