Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Good Morning,
I am developing an on line test application. I have multiple word file in I have about 50 question in each file. The format of word File is as follows:

1. What is ur name?

a. Tom
b. Harry
c. Jack
d. Daniel

Like these I have 50 questions in each word file. On my Page Links are available when I click on link a word document file related to that should be opened in that same window. Is it possible to open word file on an asp.net page? If yes how? Please help me out.

I am trying it with this piece of code but not working.
C#
string FullFilePath =//path of file //"D:\\ASP\\ASP.doc";
FileInfo file = new FileInfo(FullFilePath);
if (file.Exists)
{
    Response.ContentType = "application/vnd.ms-word";
    Response.AddHeader("Content-Disposition", "inline; filename=\"" + file.Name + "\"");
    Response.AddHeader("Content-Length", file.Length.ToString());
    Response.TransmitFile(file.FullName);
}



Please suggest some other possible solutions:
Posted
Comments
Sandeep Mewara 2-May-12 1:28am    
Getting any error?
Qureshali 2-May-12 1:31am    
It could not find the file. My file is stored in my project in Files folder.
.../Files/abc.docx
So, my statement is:
string FullFilePath =".../Files/abc.docx";
But when debugger comes to if(file.exists) it doesn't go inside the condition
Qureshali 2-May-12 1:34am    
Also this above code is for downloading the file....

1 solution

For opening word file on your web page you can go like this...


1) provide any text editor to your page.
2) read your word file using Interop assemblies like word,excel etc.
3) and after read complete display that file content into your text editor or display that on your page.



for more information on word Interop please see this link.
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx[^]

http://www.dotnetperls.com/word[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900