thisReader["text"] (这里的text字段是一个OLE字段)现在怎样使用Stream将其写成一个磁盘文件

解决方案 »

  1.   

    if (thisReaderText.Read())
    {
        Byte[] thisByte = new byte[324720];
        thisByte = (byte[])thisReaderText["text"];
        StreamWriter saveFile = new StreamWriter(@"C:\tmpText001.mdi",false);
        saveFile.Write(thisByte);
        saveFile.Close();
    }这样存下来的文件只有几个字节。其中324720也是本人没有办法手工写上去的数字,
    请各位给以更正。
      

  2.   

    if you look at the type of thisReader["text"],thisReader["text"].GetType().Nameit is likely byte[], try something likeSystem.IO.FileStream fs = new System.IO.FileStream("yourfilename.dat", System.IO.FileMode.Create, System.IO.FileAccess.Write);
    byte[] bs = (byte[])thisReader["text"];
    fs.Write(bs, 0, bs.Length);
    fs.Close();also seeHow to read and write a file to and from a BLOB column by using chunking in ADO.NET and Visual C# .NET
    http://support.microsoft.com/default.aspx?scid=kb;en-us;317043