display word document in web form
Hi, I have an application that allows the site manager to upload a word document which he wants displayed to the site users. The upload works fine however the display doesn't work. It works for txt, images and html but not for .doc files. When I want to diplay a word document it jumps to the catch phrase. Any help will be appreciated. Thanks Below is the code (text refers to the file name that is stored in the db). Function ShowDocument If Path.GetExtension(text) = ".doc" Or Path.GetExtension(text) = ".txt" Or Path.GetExtension(text) = ".html" Or Path.GetExtension (text) = ".htm" Then Dim f As Integer = FreeFile() Try If Path.GetExtension(text) = ".doc" Or Path.GetExtension(text) = ".txt" Or Path.GetExtension(text) = ".html" Or Path.GetExtension(text) = ".htm" Then FileOpen(f, Server.MapPath("../lawImages/" & text), OpenMode.Input) End If Dim myHTML = InputString(f, LOF(f)) FileClose(f) Return "<TD vAlign=""middle"" align=""center"" width=""50px"" height=""50px"">" & myHTML & "" Catch Return "<div align=center><Img src=""https://timg.co.il/f/police.jpg "" id=""img"" height=""50"" width=""50""></div>" End Try Else Return text End If End Function ____________________________________________________________- I also tried the following code but it also shows garbage of the word document: 'Set the appropriate ContentType. Response.ContentType = "application/msword" 'Get the physical path to the file. Dim FilePath As String = Server.MapPath("../lawImages/" & text) 'Write the file directly to the HTTP output stream. Response.WriteFile(FilePath) Response.End()