I am generating word documents from a template, by customizing it for the user using merge field. For example: Name: "User's name". Right now I save the documents on the server using
object miss = System.Reflection.Missing.Value;
object oDocName = "C:\\Users\\admin\\Desktop\\test002.doc";
wordDoc.SaveAs(ref oDocName, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
((_Application)wordApp).Quit(ref miss, ref miss, ref miss);
then, i make the document available for download:
protected void download_Click(object sender, EventArgs e)
{
FileStream fileStream = new FileStream("C:\\Users\\ebimbari\\Desktop\\test002.doc", FileMode.Open);
int fileSize = (int)fileStream.Length;
byte[] Buffer = new byte[fileSize];
fileStream.Read(Buffer, 0, fileSize);
fileStream.Close();
Response.ContentType = ContType("C:\\Users\\admin\\Desktop\\test002.doc");
Response.BinaryWrite(Buffer);
Response.AddHeader("content-disposition", "attachment;filename=\"" + "form" + ".doc");
Response.End();
}
The problem is that I don't want the form to be saved on the server. Can I directly open the document of make it avaiable for download? I'm using Microsoft.Office.Interop.Word
Thanks.