嵌入Word文件作为资源 [英] Embedding a word file as a resource
问题描述
我想从我的C#代码访问一个字的文件。我要将它作为项目的一部分,这样当我调用Word文档对象从一个aspx页面读取,它是从使用对象应该具有访问该Word文档不管。那么,如何可以包括Word文档作为我的项目的资源?另外为了打开我的Word文档,我需要那个文件夹的路径。我已经包括了文件作为资源之后,我怎么莫名其妙地得到它的路径,所以Word文档对象可以创造出来的?有什么方法把它在复制到任何机器调用该对象的临时位置?
I am trying to access a word file from my c# code. I want to embed it as part of a project so that when i call a word doc object to be read from an aspx page, the object should have access to that word doc no matter where it is being used from. So how can i include a word doc as a resource in my project? Also in order to open my word doc, i need a path for that doc. After i have included the file as a resource, how do i somehow get its "path" so the word doc object can be created? Is there someway to copy it over to a temp location on whatever machine is calling that object?
感谢
推荐答案
注意:不要在服务器环境中使用的MSWord
Note: Do not use MSWord in server environment.
获取流使用Stream.CopyTo后,将其保存到的上的临时文件创建的FileStream的 Path.GetTempFileName 或在的临时文件夹。
After getting the stream use Stream.CopyTo to save it to FileStream created on temporary file Path.GetTempFileName or in temp folder .
这篇关于嵌入Word文件作为资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!