Hi
I'm trying to read RTF and Word files from blob columns in SQL Server, but
the files can't be opened in Word when i retreive them. They seem to contain
garbage... What am I doing wrong?
This is some of the code used to get the files:
FileStream fileStream = new FileStream(filename, FileMode.Create,
FileAccess.Write);
BinaryWriter binaryWriter = new BinaryWriter(fileStream);
long totalBytes = sqlDataReader.GetBytes(blobColumn, 0, null, 0,
int.MaxValue);
byte[] outbyte = new byte[totalBytes];
sqlDataReader.GetBytes(blobColumn, 0, outbyte, 0, (int)totalBytes);
binaryWriter.Write(outbyte, 0, (int)totalBytes);
binaryWriter.Flush();
binaryWriter.Close();
fileStream.Close();
Joerg Jooss - 09 Jul 2006 10:02 GMT
Thus wrote excession,
> Hi
>
[quoted text clipped - 16 lines]
> binaryWriter.Close();
> fileStream.Close();
Using a BinaryWriter for arbitrary binary content is a potentially destructive
operation. To copy the data "as is", write it directly to your FileStream.
Cheers,

Signature
Joerg Jooss
news-reply@joergjooss.de