on 10-17-2005 6:49 AM
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
Just remove the
Response.Flush()
from your code to make it work.
Regards,
Yehuda
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.