cancel
Showing results for 
Search instead for 
Did you mean: 

EP 6.0 and Streaming Files to the browser

Former Member
0 Kudos

Hi there,

I'm done plenty of file streaming using BSP and Java now I need to do it in .NET. What I'm doing is I create an Excel file on the server and then try to stream it directly to the browser. My code is as follows and WORKS in a "standard" ASP.NET application BUT NOT in the SAP Portal application:

Private Sub StreamExcelFile(ByVal FilePath As String)

Dim strFileSize As String

Dim fso As Object = Server.CreateObject("scripting.filesystemobject")

Dim f As Object = fso.getfile(FilePath)

strFileSize = f.size

Const adTypeBinary = 1

Response.Clear()

Dim binaryData() As Byte

Dim FileStream As FileStream

FileStream = New System.IO.FileStream(FilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)

ReDim binaryData(FileStream.Length)

FileStream.Read(binaryData, 0, FileStream.Length)

Response.AddHeader("Content-Disposition", "attachment; filename=mytestfile.xls")

Response.AddHeader("Content-Length", strFileSize)

Response.Charset = "UTF-8"

Response.ContentType = "application/vnd.ms-excel"

Response.BinaryWrite(binaryData)

Response.Flush()

FileStream.Close()

End Sub

It brings up the "file open save dialog" but thats it.....the saved file has ZERO bytes. The funny thing is that it does work in a normal ASP.NET app? Also, some of my BSP applications that stream SmartForms from SAP to the browser still work? Does the EP 6.0 environment "manipulate" the binary in some way? Has it perhaps got something to do with COMPRESSION??

Any help would be greatly appreciated.....

Thanks

Lynton

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Just remove the

Response.Flush()

from your code to make it work.

Regards,

Yehuda