New Image

New Image

Forum member · Nov 17, 2011
When creating a new Image, the constructor takes a string as the file path. This path seems to want to accept a path relative to the file system root (C:\), but I am using a web server. My code: Dim img As Image = New Image("/Pages/Images/myimage.gif", 0, 0) This should read from the root of the webserver. However, the code keeps throwing an error Could not find a part of the path 'C:\Pages\Images\myimage.gif' Why is framework looking at C:\ ?

Re: New Image

Support · Nov 17, 2011
Hello, In ASP.NET you have use Server.MapPath() method to resolve the paths. Below line of code will give you the path from the root of your webserver. Dim img As Image = New Image(Server.MapPath("/Pages/Images/myimage.gif"), 0, 0) Thanks, ceTe Software Support Team.