Reputation: 6186
i am working in asp .net mvc3.
i want to get a image which exist in this location in my project G:\projects\CalcoWoms\CalcoWOMS\Content\pictures\calcologo.png
CalcoWOMS is my project name. i want to fetch this calcologo.png in following line please check following line and tell me how should write this following line in correct way.?
iTextSharp.text.Image gif = iTextSharp.text.Image.GetInstance("~/calcologo.png");
means in place of ("~/calcologo.png"); what path i should write ?
Upvotes: 4
Views: 6032
Reputation: 78457
You could use MapPath
var physicalPath = Server.MapPath("~/Content/pictures/calcologo.png");
Upvotes: 5
Reputation: 6914
You could use the HostingEnvironment object along with Path.Combine
Path.Combine(@HostingEnvironment.ApplicationPhysicalPath, "calcologo.png");
Of course, @HostingEnvironment.ApplicationPhysicalPath will only take you to the root of your application, so you might need to use "Content/picturescalcologo.png".
Upvotes: 0