writing binary data to word file

vpsingh

New member
Joined
Feb 9, 2005
Messages
2
Programming Experience
1-3
hi to alli am trying to write binary data to a word file.
my data is in a byte array which has been fetch from database with field type as image. I want to see it English.. I've tried many other options but basic problem is that i want something in the filestrem so that it will write binary data into word file in doc format....plz help me ASAP it's argent....
I am writing the code of the function..

PublicFunction writeFileData(ByVal strFilePath AsString, _

ByVal bytFileData() AsByte)

Try

'To write the file data

Dim fs As FileStream

'To write binary data

Dim bw As BinaryWriter

fs =
New FileStream(strFilePath, FileMode.Create, FileAccess.Write)

bw =
New BinaryWriter(fs)

bw.Write(bytFileData)

bw.Flush()

'close the output file

bw.Close()

fs.Close()

Catch ex As IOException

Throw ex

EndTry

 
Last edited:
actually i am saving whole content of my word file in database, and now i want to retrieve it from the database. column datatype is image so my data is in byte array which i want to write to my doc file. it is showing me byte code only. that's the main problem.

I can't save it .txt format because i want to preserve formatting of mr word doc.

so do you have any other option.
if you see the code you will find that prblem is in only two lines in which i am writing data to the file..
 
Hi
try this one...............

Dim strWrites As FileStream

If sfdFile.ShowDialog = DialogResult.OK Then

If File.Exists(sfdFile.FileName) Then

File.Delete(sfdFile.FileName)

End If

strWrites = File.Create("c:\abc.doc")

'Below pi_arrbyteFiles is a Array of bytes read from DB having Type Image....
strWrites.Write(pi_arrbyteFiles, 0, pi_arrbyteFiles.Length - 1)

strWrites.Close()

End If


I hope this will help u....................

Regards,
Ritesh
 
Back
Top