Starting question: picture location.

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.
 
K

KMA

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.
 
K

Kevin Spencer

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.
 
Q

Qwert

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top