-6

i am getting above exception for line of code below:

 System.Net.WebClient wc = new System.Net.WebClient();
 byte[] data = wc.DownloadData(xmlTempNode.Attributes["imageurl"].Value.ToString());
 MemoryStream ms = new MemoryStream(data);
 System.Drawing.Image img = System.Drawing.Image.FromStream(ms);
 string strImagePath = pptdirectoryPath + "\\" + currentSlide + "_" + shape.Id + ".png";
 img.Save(strImagePath);
 Microsoft.Office.Interop.PowerPoint.Shape sp = shape;

 xmlTempNode.Attributes["imgwidth"].Value = xmlTempNode.Attributes["imgwidth"].Value.Replace("px", "");
 xmlTempNode.Attributes["imgheight"].Value = xmlTempNode.Attributes["imgheight"].Value.Replace("px", "");

 //Getting exception on below line
 shape.Fill.UserPicture(strImagePath);

and strImagePath is D:\projects\MAMMP\trunk\Applications\Applications.Web\\cache\ppt\60ba9d41-00e0-44fd-9c2c-7591c881a1a0\\6_1026.png

any help guys.

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
  • BTW: the Title is complete wrong... Tags also... Jes... No wonder it got downvotes... – Smartis has left SO again Jul 01 '13 at 12:38
  • First, your Title is not a Question, it's just the short Exception Text. Second your Tags (Powerpoint,..) haven't absolutely nothing to do with this Problem. http://stackoverflow.com/help/dont-ask – Smartis has left SO again Jul 01 '13 at 12:57
  • 1
    @Smartis:i dont know the root of this problem.and i am not finding anything with such exception for interop. and every answer is referring to different different problem in various cases – Milind Anantwar Jul 01 '13 at 13:03
  • E_FAIL is a generic unknown error. There is no more specific information. Rather than searching for E_FAIL, I'd search for support more specific to some of the COM components you are using, specifically which one actually returned this error if you can find it out. – Smartis has left SO again Jul 01 '13 at 13:10

1 Answers1

2

Don't mix

\\

and

\

in the String Path.

Maybe it should look like:

string strImagePath = pptdirectoryPath + currentSlide + "_" + shape.Id + ".png";

The pptdirectoryPath string has also a backslash to much.


A single backslash is a so-called 'escape' character. This is used to include special characters like tab (\t) or a new line (\n). In order to specify a backslash in the case of a path you will have to 'espace' the single slash using the escape character, which means that you will have to write a double backslash.