Free Support Forum - aspose.com

Adding Picture on the Slide

Hi!

I am currently evaluating the ASPOSE.Slides for an ASP.Net application. So far everything works great! I am currently having problem inserting a picture on a slide. The picture is located on a web site. I used the following line of code with full URL to the picture as the filepath but the code blew up. Can you help shed some light on workarounds?? Thank you!

Picture pic = new Picture(pres, "https://...");

Error Message shown as below:

System.NotSupportedException was unhandled by user code
Message="The given path's format is not supported."
Source="mscorlib"
StackTrace:
at System.Security.Util.StringExpressionSet.CanonicalizePath(String path, Boolean needFullPath)
at System.Security.Util.StringExpressionSet.CreateListFromExpressions(String[] str, Boolean needFullPath)
at System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAccess access, AccessControlActions control, String[] pathListOrig, Boolean checkForDuplicates, Boolean needFullPath, Boolean copyPathList)
at System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess access, AccessControlActions control, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at PPTExport.processSlide(Presentation lpres) in c:\inetpub\wwwroot\forecast\PPTExport.aspx.vb:line 68
at PPTExport.exportPPT() in c:\inetpub\wwwroot\forecast\PPTExport.aspx.vb:line 29
at PPTExport.Page_Load(Object sender, EventArgs e) in c:\inetpub\wwwroot\forecast\PPTExport.aspx.vb:line 16
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

No, it will not work. First download the file and then use it

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

e.g

WebClient Client = new WebClient ();

Stream strm = Client.OpenRead ("https://www.samplesite.com/yourpicture.jpg");

Picture pic = new Picture(pres, strm);

For upload/downloading file in C#, see this link

http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=115