System.IO.Packaging Missing Override in [Content_Types].xml file

237 views Asked by At

I am facing the problem that was discussed here [Content_Types].xml <Override> element missing.

Proposed solution is

Uri File1_rel = new Uri(@"/OddContent/File1.xml", UriKind.Relative);
Uri File2_rel = new Uri(@"/OddContent/File2.xml", UriKind.Relative);

using (ZipPackage exPkg = (ZipPackage)Package.Open(String.Format(@"{0}\Temp.zip", Dir), FileMode.Create))
{
    ZipPackagePart p2 = (ZipPackagePart)exPkg.CreatePart(File2_rel, System.Net.Mime.MediaTypeNames.Text.Xml);
    ZipPackagePart File1Part = (ZipPackagePart)exPkg.CreatePart(File1_rel, "application/vnd.openxmlformats-officedocument.wordprocessingml.documents.main+xml");

As per this, if we add an additional xml file i.e. File1.xml then [Content_Types].xml file will have the Override element. However, the package will also contain the dummy File1.xml which should be avoided. Is there any other way to add the Override element in [Content_Types].xml without adding any additional xml file.

Thank You.

0

There are 0 answers