G
Guest
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();
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();