I have a word file stored in a path.
I want to open it using C# code on click of a link.
How to Proceed?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Apr 19, 2011, 5:31 PM
VulpesPosted Apr 19, 2011, 5:32 AM
System.Diagnostics.Process.Start(fullFilePath); // .doc or .docx
Ankit NandekarPosted Apr 19, 2011, 1:04 AM
private string GetDocumentMimeType(string fileName)
{
//string mimeType = "application/unknown";
string mimeType = "application/vnd.msword.document.12";
string ext = System.IO.Path.GetExtension(fileName).ToLower();
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext);
if (regKey != null && regKey.GetValue("Content Type") != null)
mimeType = regKey.GetValue("Content Type").ToString();
return "//" + mimeType;
}
For more detail Search article
Sahil JaniPosted Apr 19, 2011, 12:33 AM
Sorry once again.
Chandra Sekhar KPosted Apr 19, 2011, 12:14 AM
Sahil JaniPosted Apr 18, 2011, 3:10 AM
Above code is only for opening a word file but if you want to open any filetype means any file's extention see the attached file overhere.
If you found this answer as helpfull to you then marked this answer as an "ACCEPTED ANSWER"
Sahil JaniPosted Apr 18, 2011, 3:06 AM
Try this code... This will help you out.. . :
Response.Clear();
Response.ContentType = "application/msword"; //change the content here based on different files type
Response.AddHeader("Content-Disposition", "inline;filename=abc.doc");
Response.WriteFile();
Response.End();
Response.Flush();
If you found this answer as helpfull to you then marked this answer as an "ACCEPTED ANSWER"