Error message when attaching files programmatically

T

tadhgc

Hi

I get the following error message when I try to attach a file:
"'#PCDATA' is in nil content."

I am using the "ToBase64String" to convert the text file to a base64
string. I have verified that the conversion works correctly.
Then (and this may be what I am doing wrong) I am assigning the "text"
property of my IXMLDOMNode to this base64 string.


So my code is something like:

IXMLDOMNode oLogFileAttachment =
thisXDocument.DOM.selectSingleNode("//my:StdBVTLog");
...
//do file conversion to Base64
// return Base64 string
oLogFileAttachment.text = Base64Str;
From having a quick search for this error message on the internet, I've
seen that this error is generated due to the "xsi:nil="true""
attribute.
To quote: "When this attribute is set to true, any text value of the
XML node produces XML that is not valid. Therefore, Microsoft Office
InfoPath does not accept the value, and you receive the error message."


Since I believe this attribute is ONLY saved to the XML when a file is
not attached then it would imply that the code I've used to attach the
file has failed.


Can anyone help with this?

thanks
Tadhg
 
G

G. Tarazi

The files are not just base 64, there is a file header that InfoPath adds at
the beginning of the file, you must add it programmatically.



We had this problem last year, and I've searched the blogs on the internet,
fond the structure on one of the blogs, and then wrote an encoder/decoder.



It is simple; the header includes a version number of InfoPath as I remember
the file size, and the name, + the file, I guess you may find more searching
the blogs, I don't have the code in front of me right now, sorry
 
T

tadhgc

Hi

Yes I found it and it worked.

Only I now have security issues with the Trusted form setup.

Basically I have given my code group and my local form full trust
permissions and published it to my sharepoint site. So when I open a
form from the sharepoint site it correctly attaches the file.
But since I can't sign the form within the Vstudio Infopath project,
everytime I try to debug the project it recompiles and changes the form
back to level 2 and then I get a security error.

any ideas?
thanks
Tadhg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top