R
Russ
I am trying to convert this VB code to C#. Can someone give me a hand. The
code is for exporting a crystal report to a PDF using a memory stream.
Here is the VB:
Dim s As System.IO.MemoryStream =
oRpt.ExportToStream(ExportFormatType.PortableDocFormat)
' the code below will create pdfs in memory and stream them to the
browser
' instead of creating files on disk.
With HttpContext.Current.Response
.ClearContent()
.ClearHeaders()
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline; filename=Report.pdf")
.BinaryWrite(s.ToArray)
.End()
End With
Here is what I thought would be the C# translation:
System.IO.MemoryStream mystream = new System.IO.MemoryStream();
mystream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;
filename=Report.pdf");
HttpContext.Current.Response.BinaryWrite(mystream.ToArray());
HttpContext.Current.Response.End();
The compiler gives a error on the second line of this code stating 'cannot
convert from System.IO.stream to System,IO.MemoryStream
Thanks for the help,
Russ
code is for exporting a crystal report to a PDF using a memory stream.
Here is the VB:
Dim s As System.IO.MemoryStream =
oRpt.ExportToStream(ExportFormatType.PortableDocFormat)
' the code below will create pdfs in memory and stream them to the
browser
' instead of creating files on disk.
With HttpContext.Current.Response
.ClearContent()
.ClearHeaders()
.ContentType = "application/pdf"
.AddHeader("Content-Disposition", "inline; filename=Report.pdf")
.BinaryWrite(s.ToArray)
.End()
End With
Here is what I thought would be the C# translation:
System.IO.MemoryStream mystream = new System.IO.MemoryStream();
mystream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat);
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ContentType = "application/pdf";
HttpContext.Current.Response.AddHeader("Content-Disposition", "inline;
filename=Report.pdf");
HttpContext.Current.Response.BinaryWrite(mystream.ToArray());
HttpContext.Current.Response.End();
The compiler gives a error on the second line of this code stating 'cannot
convert from System.IO.stream to System,IO.MemoryStream
Thanks for the help,
Russ