Reputation: 6577
I have created one asp.net application which has one functionality of conversion of Html table to word Document. I had done this successfully. But now i will need to protect my file with password. Is it possible to make the file as secure by adding password. My conversion code is shown below.
Response.ClearContent();
Response.Buffer = true;
Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", DateTime.Today.ToShortDateString().Replace("/", "").Replace("-", "") + "_" + DateTime.Now.ToShortDateString() + ".doc"));
Response.ContentType = "application/ms-word";
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
tblMain.RenderControl(htw);
string strPath = Request.PhysicalApplicationPath + "Test.doc";
StreamWriter sWriter = new StreamWriter(strPath);
sWriter.Write(sw.ToString());
sWriter.Close();
Please help me, if there any way to add password to the saving files. Thanks in advance..
Upvotes: 0
Views: 3918
Reputation: 98
This is C# but looks to be the properties you are looking for.
ThisDocument.SaveAs("c:\test\MyNewDocument.doc")
// C#
Object fileName = @"C:\Test\MyNewDocument.doc";
Object password = Type.Missing;
Object writePassword = Type.Missing;
ThisDocument.SaveAs(ref fileName, ref password, ref writePassword);
http://msdn.microsoft.com/en-us/library/office/aa192495(v=office.11).aspx
Upvotes: 1