Forum Moderators: open

Message Too Old, No Replies

.NET memStream and Return Value

         

scoobydoo987

5:42 pm on Mar 10, 2006 (gmt 0)

10+ Year Member



'-- On results.aspx.vb
Dim memStream = PDF.getPDF(oDict)
Response.BinaryWrite(memStream.ToArray())

'-- On PDF.vb
'-- I need to pass back the value of filename to results.aspx.vb
'-- How would I go about doing that?
'-- I thought I could add filename to the Return but it didn't work.
'-- Don't know much about memStream
Public Shared Function getPDF(ByVal oDict As Dictionary) As System.IO.MemoryStream
Dim rpt
Dim sb As New StringBuilder
Dim pdfPath As String = System.AppDomain.CurrentDomain.BaseDirectory() & "tempPDFs"

If Not System.IO.Directory.Exists(pdfPath) Then
System.IO.Directory.CreateDirectory(pdfPath)
End If

Dim output_type As String = oDict("file")

rpt = New rptBound

Dim localFS As String = System.IO.Path.GetDirectoryName(pdfPath)
Dim uniEncoding As New UnicodeEncoding
Dim memStream As New MemoryStream(1000)
Dim _xPDF As New Export.Pdf.PdfExport
Dim filename As String = pdf.GetRandomFileName(localFS + "\tempPDFs", "rptBound" & "_", "pdf")
_xPDF.Export(rpt.Document, filename)
Dim fs As Byte() = uniEncoding.GetBytes(filename)
memStream.Write(fs, 0, fs.Length)
'-- Need to return the value of filename
Return memStream
End Function

paulanthony

6:12 pm on Mar 11, 2006 (gmt 0)

10+ Year Member



I dont quite understand what you are trying to do - are you forcing pdf creation / download to the client? Why do you need to return the file name - the function will / can only return a memory stream not a string when it is declared as

system.io.memorystream....

im confused.