I’m trying to convert the relative path to the absolute path with System.Web.VirtualPathUtility.ToAbsolute()
But I got this error:
The relative virtual path ‘./images/gift-card.jpg’ is not allowed here.
By the way, the file structure is
this code is in a .cs file and this file is in the same folder (let’s say /root) with other .aspx files. The image is in a folder, /root/images/
Any ideas?
ps:
even I change the path to ‘~/images/gift-card.jpg’ it still throws an exception: Unhandled Exception without further information.
I found the solution
Server.MapPath(“~/path/file.ext”)
This perfectly solved my problem and it was the method I was looking for.
Thank you all for your input.
Cheers