saifullah khan

saifullah khan

  • NA
  • 335
  • 301.9k

could not open the file.

Oct 28 2011 12:54 PM
hi
 
i have created an app that uploads files to a folder and then takes the files from that folder and convert it to images.
here is the code
if (FileUpload1.HasFile)
            {
              
                  string file = System.IO.Path.GetFullPath(FileUpload1.PostedFile.FileName);
                  string filname = FileUpload1.PostedFile.FileName;
//UPLOADS THE FILE INTO THE FOLDER
                  FileUpload1.PostedFile.SaveAs(Server.MapPath("~\\NewFolder1\\") + FileUpload1.FileName);
//TAKES THE PATH and file
                  string strPath = Server.MapPath(Request.ApplicationPath) + "~/NewFolder1/" + filname;
//assign the file to ppt
ApplicationClass pptApplication = new ApplicationClass();
                  Presentation pptPresentation = pptApplication.Presentations.Open(strPath, MsoTriState.msoFalse,
                  MsoTriState.msoFalse, MsoTriState.msoFalse);
 
                  var slides = new List<string>();
                  targetPath = Server.MapPath("~/NewFolder1/");
                  targetPath += "\\{0}";
                  for (var i = 1; i <= pptPresentation.Slides.Count; i++)
                  {
                  .
                  .
 
but when i run the app it gives the follwoing error.
System.Runtime.InteropServices.COMException: PowerPoint could not open the file.
Presentation pptPresentation = pptApplication.Presentations.Open(strPath, MsoTriState.msoFalse....
 
please tell me where is the problem and what i need to correct

Answers (2)