Invalid File

I ran into this issue before, but found it was because I was using .ppt and .pptx within the same library which caused issues. Now I am only using true .pptx and .potx files, but when I generate a .pptx I am getting this error message:


"powerpoint cannot open the file ‘c:\data\output.pptx’ because the file format of rile extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

Any ideas?

Here is how I am generating my document…


private static PresentationEx CreateAsposePresentation(IPresentationModel presentationModel, bool addModules)
{
PresentationEx newPresentation = new PresentationEx(presentationModel.MasterTemplate.FileLocation);

MasterSlideEx sourceMaster = GetMasterSlide(presentationModel, newPresentation);
foreach (Module module in presentationModel.Data)
{
PresentationEx presentation = new PresentationEx(module.FileLocation);
foreach (SlideEx slide in presentation.Slides)
{
newPresentation.Slides.AddClone(slide, sourceMaster);
}
}
}

I’ve narrowed it down to…



PresentationEx newPresentation = new PresentationEx(MasterTemplate.FileLocation);
newPresentation.Write(fileLocation);


I am assuming this points to something inside the template file I am using?

Hi,

How can i help you when you are using some external functions implemented? You are certainly making some mistake while cloning pptx slides. Here is a working example of slide cloning the you can compare it with your implementation (Note: out.pptx is only an empty presentation without any slides):

PresentationEx srcPres = new PresentationEx("d:\\ppt\\testClone.pptx");

PresentationEx targetPres= new PresentationEx("d:\\ppt\\out.pptx");

MasterSlideEx srcSlideMaster = srcPres.Slides[0].LayoutSlide.MasterSlide;

int index = targetPres.Masters.AddClone(srcSlideMaster);

MasterSlideEx targetSlideMaster = targetPres.Masters[index];

foreach (SlideEx sld in srcPres.Slides )

targetPres.Slides.AddClone(sld, targetSlideMaster);

targetPres.Write("d:\\ppt\\outputTEST1.pptx");

If you look at my last post, I striped out all clone and external methods... just a new presentation from a .potx file and then a write to "c:\data\output.pptx". Does this mean I have to create a new presentation using a blank .pptx file instead of this way? This is the same code but upgraded that I was using sucesfully with .ppt and .pot files.

Thoughts?

NickChristy:
I've narrowed it down to...


PresentationEx newPresentation = new PresentationEx(MasterTemplate.FileLocation);
newPresentation.Write(fileLocation);


I am assuming this points to something inside the template file I am using?

Hi,

Yes. I mean that.