生成.wmv文件零字节

时间:2012-11-15 11:10:54

标签: c# powerpoint

大家好,这是我在C#中的代码,我读了一个.ppptx文件并将其转换为.wmv由于某种原因它会生成一个零大小的文件。当我保存它是一个gif它工作正常,我找不到原因..

using Microsoft.Office.Core;
using Microsoft.Office.Interop.PowerPoint;
using ppt = Microsoft.Office.Interop.PowerPoint;
using System.Runtime.InteropServices;
using System;

namespace PowerPoint
{
    class Program
    {
    static void Main(string[] args)
    {
        //{0} source path filename
        //{1} destination path
        var app = new ppt.Application();

       // ppt.Presentation file = app.Presentations.Open(args[0], MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
        ppt.Presentation file = app.Presentations.Open(@"C:\Users\mkolozoff\Desktop\tutorial1.pptx", MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);

       // file.SaveCopyAs(args[1], PpSaveAsFileType.ppSaveAsWMV);
        file.SaveCopyAs(@"C:\Users\mkolozoff\Desktop\demo.wmv", PpSaveAsFileType.ppSaveAsWMV);

        file.Close();
        app.Quit();

        Marshal.ReleaseComObject(file);
        Marshal.ReleaseComObject(app);

        file = null;
        app = null;

        GC.Collect();
        GC.WaitForPendingFinalizers();

    }
}
}

0 个答案:

没有答案