R
Richard Wilde
Hi
I have found on the internet a way to write out an xml file direct to the
browser so as the save as box is displayed on a click of a button. All works
well apart with non unicode data. However as soon as I have unicode data I
only get an empty file (well a file with blanks or I assume spaces). This
must be something to do that unicode data is 2 bytes and my code does not
allow for that as the conversion of byte only takes the top byte.
I have tried without success to find out how to solve this problem. Can
anyone help?
Many thanks
Richard
Dim ds As DataSet
Dim fStream As New System.IO.MemoryStream
'fill the dataset
ds = DBTools.GetExportDataForReport()
'Write dataset to the memory stream
ds.WriteXml(fStream)
'write out memory stream to disk
Dim b(CType(fStream.Length, Int32)) As Byte
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/unknown"
Response.AddHeader("Content-Disposition", "attachment;filename=export.xml")
fStream.Read(b, 0, CType(fStream.Length, Int32))
Response.BinaryWrite(b)
Response.End()
fStream.Flush()
fStream.Close()
fStream = Nothing
I have found on the internet a way to write out an xml file direct to the
browser so as the save as box is displayed on a click of a button. All works
well apart with non unicode data. However as soon as I have unicode data I
only get an empty file (well a file with blanks or I assume spaces). This
must be something to do that unicode data is 2 bytes and my code does not
allow for that as the conversion of byte only takes the top byte.
I have tried without success to find out how to solve this problem. Can
anyone help?
Many thanks
Richard
Dim ds As DataSet
Dim fStream As New System.IO.MemoryStream
'fill the dataset
ds = DBTools.GetExportDataForReport()
'Write dataset to the memory stream
ds.WriteXml(fStream)
'write out memory stream to disk
Dim b(CType(fStream.Length, Int32)) As Byte
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/unknown"
Response.AddHeader("Content-Disposition", "attachment;filename=export.xml")
fStream.Read(b, 0, CType(fStream.Length, Int32))
Response.BinaryWrite(b)
Response.End()
fStream.Flush()
fStream.Close()
fStream = Nothing