Click here to Skip to main content
15,885,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i
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
C#
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....


In this line of code i am getting this above exception
C#
pptApplication.Presentations.Open(strPath, MsoTriState.msoFalse,
                  MsoTriState.msoFalse, MsoTriState.msoFalse);

[Edit]Code block added[/Edit]
Posted
Updated 22-Dec-12 0:42am
v3
Comments
Jibesh 22-Dec-12 8:41am    
Please do not post the same question again and again with different header.

http://www.codeproject.com/Questions/513973/Iplusamplustryingplustoplusopenplusppt

you may edit your question using the green 'Improve Question' link at the right bottom of your question to modify. do value others time posting redundant answers to the same questions multiple time.

1 solution

Hi , firts thing that come to my mind is the line of your code:
C#
string strPath = Server.MapPath(Request.ApplicationPath) + "~/NewFolder1/" + filname;


Maybe it could be reasonable to change it with next line:

C#
string strPath = Server.MapPath(System.IO.Path.Combine("~/NewFolder1" , filname));


think this might help you, because when you invoke next line of code , it return the full path to folder "NewFolder1" :
Server.MapPath("~/NewFolder1") -> will be something like that (c:\inetpub\wwwroot\mysite\newfolder1);
 
Share this answer
 
Comments
Pradeepkumar patil sonu 23-Dec-12 22:58pm    
Thank This is working for me...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900