tags:

views:

7

answers:

0

I have been using httphandler to view files that are stored in server. It has been working fine for most files except office 2007 documents. I m unable to open any of the word or excel files using the code i have . I have set the proper mime type for office 2007 files. It recognizes that it is trying to open an excel file, but does not open it. It throws an error saying The file format is either not correct or the file is corrupted.I have tried Response.BinaryWrite, Response.write, response.outputstream.write, but cannot figure out whats wrong. Here is a sample code...Has anyone got this working before???

 Dim fullPath As String = ""
                        fullPath = context.Server.MapPath(fileName)
                        Dim imageFile As FileInfo = New FileInfo(fullPath)
                        Dim byteArray As Byte() = File.ReadAllBytes(context.Server.MapPath(fileName))
                        context.Response.BinaryWrite(byteArray)

                        context.Response.End()