我已经创建了一个asp.net应用程序,它具有将Html表转换为word文档的一种功能。我已经成功完成了这项工作但现在我需要用密码保护我的文件。是否可以通过添加密码来使文件安全。我的转换代码如下所示。用密码保护word文档
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();
请帮助我,如果有任何方法可以将密码添加到保存文件。 在此先感谢...
其花费更多的时间通过使用此代码,打开该定位的文件。 – MAC 2013-04-01 04:59:55