Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 1.0
This is the forum to discuss the Wrox book Beginning ASP.NET 1.0 with C# by Chris Goode, John Kauffman, Christopher L. Miller, Neil Raybould, S. Srinivasa Sivakumar, Dave Sussman, Ollie Cornes, Rob Birdwell, Matt Butler, Gary Johnson, Ajoy Krishnamoorthy, Juan T. Llibre, Chris Ullman; ISBN: 9780764543708
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 1.0 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 8th, 2004, 02:49 AM
shs shs is offline
Authorized User
 
Join Date: Mar 2004
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default display content of upload file

Hi,
I have uploaded files to a folder on my computer and everything works fine. when I try to display the content of the file, I use this code:

Dim CNAME as String = Server.MapPath("..\uploaded_files\" & oComm.Parameters( "@c_randName" ).Value )
Dim oStreamReader as StreamReader
oStreamReader = File.OpenText(CNAME)
Dim fileContent as String = oStreamReader.ReadToEnd()
lblOutput.Text = fileContent
oStreamReader.Close()

this code only reads and display files with 'txt' extention, it doesn't disply 'doc' files. How can I change the code so that it can read and display .doc files correctly?
Many thanks
 
Old May 8th, 2004, 04:51 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Well, I think this code *does* display Word documents as well. However, the output will look crappy because a Word document contains a lot of bloat necessary for Word. It will also display the binary version of the document, not a textual representation of the text inside that document.

If you need to display Word documents in-line in your site, you can display them using an iframe. Simply set the src attribute of the <iframe> to the word document, like this:

<iframe src="YourDocument.doc" width="300px" height="300px" />

Depending on the browser's setup, users may be presented with a dialog asking them if they want to download and save the Word document.

Alternatively, you could do some Word Automation. I think you could create an instance of a Word Application server side, load the document and ask for its text. I don't have much experience in this subject, so you may be better off asking this in another forum.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Song For Junior by Beastie Boys (Track 14 from the album: Hello Nasty) What's This?





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to dynamic display the content of the table? myhrvod Pro Java 0 August 3rd, 2006 12:42 AM
Display pdf in content walgr2k ASP.NET 2.0 Basics 0 May 1st, 2006 05:19 PM
Whole Folder upload(Multi file Upload) ramasamy_rams XML 1 September 9th, 2005 12:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.