Using Package class but storing to SQL Server
I've got some .docx files created in Word2007, destined to be stored in SQL Server rather than in a file system. These documents have had controls mapped using the Word2007 Content Control Toolkit. My current code which deals with the file-system version of these documents uses file streams to replace the CustomXML data store after the XML has had data replaced by setting InnerText in the XML document:
customXml.LoadXml(xmlToApply);
uri =
newUri("/customXML/item1.xml",UriKind.Relative);PackagePart partOut = packageOut.GetPart(uri);using (Stream stmWritePart = partOut.GetStream(System.IO.FileMode.Create, System.IO.FileAccess.Write)){
customXml.Save(stmWritePart);
}
packageOut.Close();
In order to do the same thing with packages stored in SQL server, I need to work with a package that comes to me in memory, rather than living out on a file system. The code above depends on file streams, and it's replacing the CustomXML portion of the package out on disk, not replacing the CustomXML in a package in memory and then sending the whole package off as a BLOB to SQL. I'm sure this is simple for you DOCX jocks, but I'm at sea at the moment. Could somebody explain to me how to do package (document) manipulation when I'm not working with the file system?
I'm betting that a lot of people will eventually want to do this same thing; OpenXML and things like the Word2007 Content Control Toolkit make using documents for data presentation very powerful.
Thanks very much for any assistance!

