0

I'm recreating an old abandoned program that i created when i was learning c# which outputs a word file with the information from a form. The program extract the embedded resource which is template.docx located in Res folder to C:\ClearanceResource\template.docx then will be load by the program again using:

dox.LoadFromFile(@"C:\ClearanceResource\template.docx");

is there a better way to do this like getting the string location path of the embedded resource and using it in the dox.Loadfromfile(someStringPath) so that i dont need to create an instance of the file per run?

J M R
  • 3
  • 2

1 Answers1

2

Use LoadFromStream method.

Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("template.docx");
Document dox = new Document();
dox.LoadFromStream(stream, FileFormat.Docx);
  • @Arvie Delgado: can you please have a look at https://stackoverflow.com/questions/57953815/visual-studio-c-loadfromremotesources regarding your Roro? – Pingui Sep 16 '19 at 09:40