string filename = "1.docx";
string filepath= @"......\1.docx";
Response.Clear();
Response.AddHeader("content-disposition","attachment;filename=" + filename);
Response.ContentType = "application/force-download";
Response.WriteFile(filepath);
Response.Flush();
Response.End();
I used this code for opening the document in page load event but it's not showing rather than downloading i want a preview of the document please help me
Karthik ElumalaiPosted Jun 23, 2016, 10:16 AM
- string filepath= @"......\1.docx";
- //get the all file names inside the directory
- string[] files = Directory.GetFiles(filepath);
- //loop through the files to search file one by one
- for (int i = 0; i < files.Length; i++)
- {
- string sourcefilename = files[i];
- StreamReader sr = File.OpenText(sourcefilename);
- string sourceline = "";
- int lineno = 0;
- while ((sourceline = sr.ReadLine()) != null)
- {
}Akshay PhadkePosted Jun 21, 2016, 10:43 AM