views:

104

answers:

1

Hi,

I'm trying to load an image that is in the root dir of my project:

Dim b As Bitmap = New Bitmap("img.bmp")

but it doesn't seem to find the file.

I've tried various combinations like ~img.gif, /img.gif, \img.gif, ~/img.gif etc, but none seems to work. How to access the "current directory on server" in ASP.NET?

Thanks

+9  A: 

Have you tried:

Dim b As Bitmap = New Bitmap(HttpContext.Current.Server.MapPath("~/img.bmp"))
dommer
thats about right
TStamper
it worked, thanks
pistacchio