错误HRESULT E_FAIL已从调用返回至COM组件
问题描述:
我得到的例外上面的下面的代码行:错误HRESULT E_FAIL已从调用返回至COM组件
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);
和strImagePath
是D:\projects\MAMMP\trunk\Applications\Applications.Web\\cache\ppt\60ba9d41-00e0-44fd-9c2c-7591c881a1a0\\6_1026.png
任何帮助球员。
答
不要在路径字符串混合
\\
和
\
。
也许它应该看起来像:
string strImagePath = pptdirectoryPath + currentSlide + "_" + shape.Id + ".png";
的pptdirectoryPath字符串也有一个反斜杠得多。
单个反斜杠是所谓的“逃逸”字符。这用于包含特殊字符,如制表符(\ t)或新行(\ n)。为了在路径中指定反斜杠,您必须使用转义字符'espace'单斜线,这意味着您将不得不写入双反斜杠。
BTW:标题是完全错误的...标签也... Jes ...难怪它得到了downvotes ... – Smartis
首先,你的标题不是一个问题,它只是简短的例外文本。其次,您的标签(Powerpoint,..)与这个问题并不完全无关。 http://*.com/help/dont-ask – Smartis
@Smartis:我不知道这个问题的根源,我没有发现任何与这种例外互操作。并且每个答案在各种情况下指的是不同的问题 –