使用 ASP.Net 将存储在 SQL Server 中的 MS Office 文件直接保存到服务器目录
我正在 SQL Server 中存储 MS Office 文件,例如 PowerPoint(.ppt、.pptx)和 Word(.doc、.docx),并且需要通过 ASP.Net 应用程序将这些文件保存到服务器上的临时文件目录。我从数据库中获取文件并以字节数组的形式放入应用程序中。但我不知道如何将字节数组保存为指定目录位置中适当格式(.ppt/.pptx 等)的文件。
我知道我可以使用代码将 Response.ContentType 设置为“application/ms-word”之类的内容,然后将 Response.AddHeader 的“content-disposition”设置为“attachment”。但是,这会打开一个“另存为”对话框。我需要做的是将文件直接保存到服务器上的目录中(以便我可以对其进行一些进一步的操作)。
I am storing MS Office files such as PowerPoint (.ppt, .pptx) and Word (.doc, .docx) in SQL Server, and need to save these files to a temp file directory on the server through an ASP.Net application. I get the files up from the database and into the application as a Byte Array. But what I don’t know is how to then save the Byte Array as a file in the appropriate format (.ppt/.pptx etc) in a specified directory location.
I know that I can use code along the lines of setting the Response.ContentType to something like "application/ms-word", and then setting the “content-disposition” of Response.AddHeader to “attachment”. However, this opens a “save as” dialog. What I need to do is to save the file directly into a directory on the server (so that I can do some further operations on it).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你只需要这个:
You just need this: