'ASP.NET: Unable to cast IO.StreamWriter to IO.MemoryStream
I have a complex class module that make a lot of processing and return a object of type IO.StreamWriter, but I need cast this object to IO.MemoryStream, furthemore to Byte(). Finally it converts Byte() to Base64String that ajax consumes and generate a CSV file.
I made this with DynamicPDF.Document, but this library has a method that returns binary.
Dim objSW As IO.StreamWriter = EXP.ExportarBinario(objCommand, HttpContext.Current.Response.OutputStream, 1)
Dim objMS As New MemoryStream()
objSW.BaseStream.CopyTo(objMS)
Dim objArrayByte As Byte() = objMS.ToArray()
Dim strArrayByte64 As String = String.Format("data:{0};base64,{1}", "application/vnd.excel", Convert.ToBase64String(objArrayByte))
Return strArrayByte64
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
