0

I have a neat class that is able to mergefields within a Word document based on a Datarow object containing the data I require to turn a Word 2007 docx template into a real Word document with the data embedded inside the Word document, and using OpenXML (forget Interop!). That's working for me. However, I am having a royal pain to get the template loaded into my asp.net (.net2) project in Visual Studio 2005. Everytime I think I've "embedded" the Word document into the project, when I try and access it, I get this exception ...

Value cannot be null.

Parameter name: The Template File does not exists.

This error appears from a resource project (compiled in VS2008) DLL file that checks the existance of the file before it continues. I know that's the cause of the problem but why Fileinfo.Exists is always false, when I know the file is there!? The file is in the same server as the project resides, but in a different location to the project.

So the question really should say, why Fileinfo.Exists returns false all the time.

Never the less, I need to store this Word document inside the project itself, so my other need is to know how to embedd a Word document inside my asp.net project to keep it "contained" within the same one solution AND to get Fileinfo to recognise it DOES exist.

Thank you

Community
  • 1
  • 1
Fandango68
  • 4,461
  • 4
  • 39
  • 74
  • Why are you using Visual Studio 20015 in mid 2014? Why are you using .NET 2.0 when there is .NET 4.5? There is no real reasons for this. – abatishchev Mar 25 '14 at 02:52
  • LOL. Mate do you work for anyone? Because if you did, and they happen to want to stay with older technology, are you going to insist your boss upgrade!? Can someone please help me here and not answer a question with another question? – Fandango68 Mar 25 '14 at 02:56

1 Answers1

1

I found it!

It was simply adding the file to my existing project using Add Existing ...

I then placed the file inside a folder within my project (any folder) and simply referencing it with ...

    System.IO.File.Exists(Server.MapPath("FeedbackFormTemplate.docx"));

This generates a full path and filename with extension ready to be used elsewhere in the project.

Fandango68
  • 4,461
  • 4
  • 39
  • 74