• 读取二进制文件(字段)


    读取二进制文件:

     1    private void button1_Click(object sender, System.EventArgs e)
     2        {
     3            string path = @"E:\Test\GRFW.pdb";
     4
     5            byte[] rawSymbolStore = loadFile(path);
     6
     7            string x = "";
     8            int ArraySize = new int();
     9            ArraySize = rawSymbolStore.GetUpperBound(0);
    10                
    11            System.Text.Encoding en = System.Text.Encoding.UTF8;
    12            x = en.GetString(rawSymbolStore,0,ArraySize);
    13
    14            x = "";
    15        }

    16
    17        private byte[] loadFile(string filename) 
    18        {
    19            FileStream fs = new FileStream(filename, FileMode.Open);
    20            byte[] buffer = new byte[(int) fs.Length];
    21            fs.Read(buffer, 0, buffer.Length);
    22            fs.Close();
    23   
    24            return buffer;
    25        }



    二进制字段:
                    字段"crpd_txt"]为oracle数据库中的blob类型。
                    byte[] MyData= new byte[0];
                    string x = "";  
                    MyData =  (byte[])letdt.Rows[0]["crpd_txt"];
                   int ArraySize = new int();
                  ArraySize = MyData.GetUpperBound(0);
                   
                  System.Text.Encoding en = System.Text.Encoding.Unicode;

                  //获取二进制代表的字符串
                 x = en.GetString(MyData,0,ArraySize);

  • 相关阅读:
    关于git
    关于 素材,设计
    utiles
    sqlite
    蓝牙
    一个简单的Maven小案例
    【日志卡住不动】Registering current configuration as safe fallback point
    一分钟部署nacos
    生产日志文件太大NotePad++无法打开
    idea 安装 codota 插件
  • 原文地址:https://www.cnblogs.com/friendwang1001/p/351513.html
Copyright © 2020-2023  润新知