BinaryReader 类
用特定的编码将基元数据类型读作二进制值。

解决方案 »

  1.   

    SaveFileDialog sfd = new SaveFileDialog();
    FileStream fs; conn.Open();
    da.Fill(ds);
    theTable = ds.Tables[0]; String temp = (String)theTable.Rows[0]["FileExt"]; Byte[] myData;
    myData = (byte[])theTable.Rows[0]["BinaryData"]; sfd.DefaultExt = temp.Trim(); //获得默认扩展名

    if(sfd.ShowDialog() == DialogResult.OK)
    {
    fs = new FileStream(sfd.FileName,FileMode.Create,FileAccess.Write);
    fs.Write(myData,0,myData.Length);
    fs.Close(); }
    conn.Close();
      

  2.   

    long retval;                            // The bytes returned from GetBytes.
    long buffersize=1024;                   //Field's length
    byte[] outbyte = new byte[buffersize];  SqlCommand CMD = new SqlCommand("SELECT Fieldbyte FROM xxx", Conn);
    SqlDataReader myReader = CMD.ExecuteReader(CommandBehavior.SequentialAccess);if(myReader.Read())
    {
      retval = myReader.GetBytes(1, startIndex, outbyte, 0, bufferSize);
    }
    myReader.Close();
    pubsConn.Close();
      

  3.   

    参阅清华大学出版社引进的 Wrox 系列的 “C#数据库入门经典”的最后一章,有专门描述此类问题的专题,对于保存和导入二进制数据及(特别是图形数据)注意事项都作了详细正确的论述。值得一看,我也借此解决了我的问题。 其注意事项是我以前不了解的。