ram27
asked on
hOW to load BYTE [] data to the WebBrowser control in Windows Control
Hi
We have requirement to load "byte []" stream of data and we have to load it on WebBrower control using C#,Vs2005..net framework 2.0. Could you please provide some thoughts on this.
Thanks,
Ram.
We have requirement to load "byte []" stream of data and we have to load it on WebBrower control using C#,Vs2005..net framework 2.0. Could you please provide some thoughts on this.
Thanks,
Ram.
ASKER
Once i convert Byte[] to string how can i load this into webbrowser control. My requirement is to load contents of the file( which wold have stored in database in biary format), i will be retreive this using stored proc, once i got the byte[] array how to to load this in webbrowser control.
ASKER
I got an idea:
Want to do some thing like this:
1./retrieve it from database and assign to byte array
2. wtire to the webbrowser by using webBrowser1.DocumentStream .Write.
that i..e,
byte [] buff= (byte [])dr["DocumentContent"]; this.webBrowser1.DocumentS tream.Writ e(buff,0,b uff.Length )
But :webBrowser1.DocumentStrea m" is NUll how can we use write() method of documentstream.
Could you please suggest some solution on thi.
Want to do some thing like this:
1./retrieve it from database and assign to byte array
2. wtire to the webbrowser by using webBrowser1.DocumentStream
that i..e,
byte [] buff= (byte [])dr["DocumentContent"]; this.webBrowser1.DocumentS
But :webBrowser1.DocumentStrea
Could you please suggest some solution on thi.
try something like this:
byte [] buff= (byte [])dr["DocumentContent"];
MemoryStream ms = new MemoryStream(buff);
webBrowser1.DocumentStream = ms;
byte [] buff= (byte [])dr["DocumentContent"];
MemoryStream ms = new MemoryStream(buff);
webBrowser1.DocumentStream
don't forget:
using System.IO;
using System.IO;
sorry thry this instead:
using System.IO;
byte [] buff= (byte [])dr["DocumentContent"];
webBrowser1.DocumentStream = new MemoryStream(buff);
using System.IO;
byte [] buff= (byte [])dr["DocumentContent"];
webBrowser1.DocumentStream
ASKER
i tried what you have mentioned. but it just loads the binary stream of data. it doen not show the actual contents
can you explain how the data is saved into the database? is it saved as ascii LOB?
I did a simple test and both of these work for me:
String myHTML = "<html>simple test </html>";
byte[] myHTML_bytes = Encoding.Default.GetBytes(myHTML);
MemoryStream ms = new MemoryStream(myHTML_bytes);
webBrowser1.DocumentStream = ms;
OR
String myHTML = "<html>simple test </html>";
byte[] myHTML_bytes = Encoding.Default.GetBytes(myHTML);
webBrowser1.DocumentText = Encoding.Default.GetString(myHTML_bytes);
ASKER
Thanks for your reply i am sending file contents as "Byte []"( byte array) and it will be saved in database as 'image'. Also file type also will be saved in Database, it could be any type like . ., application/msword,applica tion/vnd.m s-excel,Ap plication/ pdf, video/wmv,image/bmp etc..
Could you please suggest required changes.
Thanks,
Ram.
Could you please suggest required changes.
Thanks,
Ram.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
check this link to know how to convert byte array to string
http://www.aspcode.net/Bytearray-to-string-and-string-to-bytearray.aspx