I am retreiving a word 2010 document that has been uploaded to a sql 2005 database. When I subsequently download and open the document in a word window it states the file is corrupted and gives the user the option of repairing the file for display. This always works fine but the corrupted message is always presented for all DOCX files. The DOC files from an older Word version work fine without incident. the section of code, VB.NET, for streaming the document out to display in Word is:
Dim bytes() AsByte = CType(dt.Rows(0).Item(2), Byte
())
Response.Buffer = True
Response.Charset =
""Response.Cache.SetCacheability(
HttpCacheability
.NoCache)
Response.ContentType = dt.Rows(0).Item(0).ToString()
Response.AddHeader(
"content-disposition", "attachment;filename="
& dt.Rows(0).Item(1).ToString())
Response.BinaryWrite(bytes)
Response.Flush()
Response.End()
Where the content type value, in this case, is "application/vnd.openxmlformats-officedocument.wordprocessingml.document" (rather than "application/vnd.ms-word"). The filename is simply the full name of the document and the data itself is loaded into the Bytes var. This is basd pretty much on code from Mudassar I got some time back... it just doesn't like the new and improved word 2010 files.
Thoughts on how to correct for this?
Thank you.