Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

MemoryStream as input to file download?

I tried using a memorystream as input to an xml file download, so I wouldn't have to create a disk file (to then delete)....

            Response.Clear()
            Response.AddHeader("Content-Disposition", "attachment; filename=" & varFileName)
            Response.ContentType = "text/XML"
            '    Response.WriteFile(varFilePath & varFileName)  < the alt way to do it

            ''---  use memorystream
            varMemTab.Position = 0
            Dim wrkStreamReader As New StreamReader(varMemTab, Encoding.UTF8)
            Dim content As String = wrkStreamReader.ReadToEnd()
            ''---- do the write
            Response.WriteFile(content)

....but it gave an http exception error like it was processing the markup in the Response.WriteFile(content) statement.

Might there be a way to make this work?

Any suggestions would be appreciated.

Thanks!

SOLUTION
Avatar of kraffay
kraffay

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codequest
codequest

ASKER

Thanks for input.  I'll give that a try a little later and postback.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for input.   Still working my way back to this one.  I'll keep it alive with posts until I fully resolve.
Still working my way back to this...
Still working on this, should get to it soon...
Avatar of Bob Learned
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I will leave the following recommendation for this question in the Cleanup topic area:
   Accept: nauman_ahmed {http:#18054518}

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

TheLearnedOne
EE Cleanup Volunteer