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
  • 相关阅读:
    数组与指针
    壁纸
    2019/1/11
    指针A
    数组B
    一起来抓老鼠啊!快乐呀!
    打印沙漏
    I think I need a boat house
    币值转换
    《C语言程序设计》编程总结汇总
  • 原文地址:https://www.cnblogs.com/supercode/p/173340.html
Copyright © 2011-2022 走看看