Starting question: picture location.

  • Thread starter Thread starter Qwert
  • Start date Start date
Q

Qwert

Hello,

I have a Webcontrol ( Inherits System.Web.UI.WebControls.WebControl, Visual
Basic ).
In this control I create and save a picture:

Dim objImgResult As Image
....
objImgResult.Save(strFilename)

It works fine, but when I don't specify the full path in 'strFilename', the
resulting image ends up in my "\Windows\system32" directory. But I want it
to end up in the directory where the main file "Index.aspx" is, or in its
"\bin" directory where the dll is with the control.

How does one do this simple task, without hardcoding the full path into the
code of the control?

Thanks.
 
You can use Server.MapPath("~");

The ~ means "Base dir". So, for example, wherever you are, "~/images" will
always point to your images directory, if you have one. It's an absolute
gem, and I'd like to thank the Spanish Govt for lending it to the .NET
community.
 
Use Server.MapPath to convert a URL to a full file path.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.
 
Thanks both, it gets the correct location.


Kevin Spencer said:
Use Server.MapPath to convert a URL to a full file path.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
What You Seek Is What You Get.
 
Back
Top