Question

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

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top