Skip to content

Create and Load file from memory with out saving to local system

Vishal G

Asked May 10, 2007, 10:53 AM EDT3 answers
Share
LinkedInX
Hi All,

I have a typical problem. I have a string which is actually a xml string. I want to load it to web browser as a xml file. 

I can do it as:- save the string as an xml file in to the local drive and supply the file path to the web browser's Navigate function. It will loads that file in to the browser.
 
But I dont want to do as I explained. Is it possible to create and load the file from memory to the web browser control. Can any one put some light in to this. If possible, I need few more options. I want to disable the drag and drop facility. 
 
Thanking you in advance
Vishal G

3 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Mike Gold
    0
    Not sure if you are asking for a client to client or server to client.  First you seem to be asking about the web browser, then about the web browser control, can you clarify?
    0
  • 0
    Hi Mike,

     .Net client is receiving collection of object from the server side. One of its field is a string ( saved xml as string in database ) . Client formats it back to xml and show to the user. I am using webbrower control to show the xml. Why I am using webbrowser is because it allows to collapse and expand the xml nodes. 

    Webbrowser requires file path to show the xml file. So for that I am doing it as follows.

    First convert that string to xml and save it as xml file in to the local drive. Supply the path to the web browser control.

    My query : If I am doing it right way. Then how I can avoid it saving to the local drive. Otherwise suggest me an alternative.

    Thanks in advance
    Vishal G

     
    0
  • Mike Gold
    0
    I think you can just get the response stream directly and place it into the control using HttpWebRequest and HttpWebResponse.  You just need to get the ResponseStream and use a MemoryStream with the stream reader, convert to a string.  Then I believe you can assign the string to the Document object in the web browser control.  (Not absolutely sure about this though...)

    -Mike
    0