我创建了一个 asp.net 应用程序,它具有将 Html 表转换为 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();
如果有任何方法可以为保存文件添加密码,请帮助我。提前致谢..