代码如下:
FUpload.SaveAs(uploadPath + "\\" + dlistClass.SelectedItem.Text + "\\" + newFileName);
//如果存储文件类型为ppt,pps,pptx则需要另存一个htm格式的文件以便支持在线浏览功能。
if (FileOpt.GetFileType(oldFileName) == ".ppt" || FileOpt.GetFileType(oldFileName) == ".pptx" || FileOpt.GetFileType(oldFileName) == ".pps")
{ ConvertToHTML(sonPath + "\\" + newFileName, pptToHtml + "\\" + newFileName);
}
return true;
/// <summary>
/// 将PPT文件转换为htm
/// </summary>
/// <param name="PptFilePath">PPT文件的绝对路径</param>
/// <param name="HtmFilePath">htm文件的绝对路径</param>
public void ConvertToHTML(string PptFilePath, string HtmFilePath)
{
string pptPath = PptFilePath;
string htmlFileName = HtmFilePath.Substring(0,HtmFilePath.Length-Path.GetExtension(HtmFilePath).Length) + ".htm";
Label1.Text = "打开文档中请稍等";
//执行到这里程序就终止了。在vs的调试模式或自带的web服务器上运行正常,移植到iis中就无法得到正常执行了。
PPT.ApplicationClass ppta = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
try
{
PPT.Presentation pptFile; pptFile = ppta.Presentations.Open(pptPath, MsoTriState.msoCTrue, MsoTriState.msoCTrue, MsoTriState.msoFalse);
Label1.Text = "保存文档中请稍等。。";
pptFile.SaveAs(htmlFileName, PPT.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTriStateToggle);
Label1.Text = "操作完成!";
pptFile.Close();
ppta.Quit();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
FUpload.SaveAs(uploadPath + "\\" + dlistClass.SelectedItem.Text + "\\" + newFileName);
//如果存储文件类型为ppt,pps,pptx则需要另存一个htm格式的文件以便支持在线浏览功能。
if (FileOpt.GetFileType(oldFileName) == ".ppt" || FileOpt.GetFileType(oldFileName) == ".pptx" || FileOpt.GetFileType(oldFileName) == ".pps")
{ ConvertToHTML(sonPath + "\\" + newFileName, pptToHtml + "\\" + newFileName);
}
return true;
/// <summary>
/// 将PPT文件转换为htm
/// </summary>
/// <param name="PptFilePath">PPT文件的绝对路径</param>
/// <param name="HtmFilePath">htm文件的绝对路径</param>
public void ConvertToHTML(string PptFilePath, string HtmFilePath)
{
string pptPath = PptFilePath;
string htmlFileName = HtmFilePath.Substring(0,HtmFilePath.Length-Path.GetExtension(HtmFilePath).Length) + ".htm";
Label1.Text = "打开文档中请稍等";
//执行到这里程序就终止了。在vs的调试模式或自带的web服务器上运行正常,移植到iis中就无法得到正常执行了。
PPT.ApplicationClass ppta = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
try
{
PPT.Presentation pptFile; pptFile = ppta.Presentations.Open(pptPath, MsoTriState.msoCTrue, MsoTriState.msoCTrue, MsoTriState.msoFalse);
Label1.Text = "保存文档中请稍等。。";
pptFile.SaveAs(htmlFileName, PPT.PpSaveAsFileType.ppSaveAsHTML, MsoTriState.msoTriStateToggle);
Label1.Text = "操作完成!";
pptFile.Close();
ppta.Quit();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
------------------------------------------------------
是不是IIS用户权限不够
using Microsoft.Office;
using Microsoft.Office.Interop.PowerPoint;
using Microsoft.Office.Interop;
using Microsoft.Office.Core;public class ConvertPowerPoint
{
/// <summary>
/// 建立对PowerPoint.Application的Com组件的引用
/// </summary>
private Microsoft.Office.Interop.PowerPoint.Application ppt;
/// <summary>
/// 指向具体的文件;
/// </summary>
private Microsoft.Office.Interop.PowerPoint.Presentation pptFile; /// <summary>
/// 构造器
/// </summary>
public ConvertPowerPoint()
{
ppt = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
}
/// <summary>
/// 转换过程
/// </summary>
/// <param name="pptFileName">欲转换的PowerPoint文件名称</param> public void Convert(string pptFileName)
{
//ppt.Presentations.OpenOld();
if (ppt == null)
return;
pptFile = ppt.Presentations.Open(pptFileName, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
pptFile.SaveAs("e:\\Project2008\\PPT_Test\\1.html", Microsoft.Office.Interop.PowerPoint.PpSaveAsFileType.ppSaveAsHTML, Microsoft.Office.Core.MsoTriState.msoCTrue);
pptFile.Close();
}
}其中:"e:\\Project2008\\PPT_Test\\1.html” 就是你的<param name="HtmFilePath">htm文件的绝对路径 </param>
到底是怎么回事郁闷中……