1

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?

Thanks

wildplasser
  • 43,142
  • 8
  • 66
  • 109
John Baum
  • 3,183
  • 11
  • 42
  • 90
  • You probably could not add the file to resources, but rather just add the file to the project to make it publish when application is deployed and reference to it with its URL (i.e. `Server.MapPath("your/path/here")`). – Lukasz M Mar 15 '12 at 20:49

1 Answers1

1

Note: Do not use MSWord in server environment.

How to embed file as resource

After getting the stream use Stream.CopyTo to save it to FileStream created on temporary file Path.GetTempFileName or in temp folder .

Community
  • 1
  • 1
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179