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
  • 相关阅读:
    JvisualVM、JMC监控远程服务器
    MVC学习笔记3
    MVC学习笔记2
    菜鸟级appium 必看
    关于redis一些问题记录
    git和github的区别
    VMware快照
    LR创建数据源读取excel
    mysql 5.7.18 源码安装笔记
    IDEA 配置Junit4
  • 原文地址:https://www.cnblogs.com/supercode/p/173340.html
Copyright © 2011-2022 走看看