读取二进制文件(字段)

读取二进制文件:

 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);

posted on 2006-03-16 16:55  皮皮虾的blog  阅读(789)  评论(0编辑  收藏  举报