大家好,这是我在 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();
}
}
}