Home All Groups Group Topic Archive Search About

Starting question: picture location.

Author
12 May 2005 10:03 AM
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.

Author
12 May 2005 11:20 AM
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.

Show quoteHide quote
"Qwert" <n***@nosp.com> wrote in message
news:gJWdnUXtquyctx7fRVnyhQ@casema.nl...
> 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.
>
>
>
>
>
Author
12 May 2005 12:01 PM
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.

Show quoteHide quote
"Qwert" <n***@nosp.com> wrote in message
news:gJWdnUXtquyctx7fRVnyhQ@casema.nl...
> 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.
>
>
>
>
>
Author
12 May 2005 2:02 PM
Qwert
Thanks both, it gets the correct location.


Show quoteHide quote
"Kevin Spencer" <kevin@DIESPAMMERSDIEtakempis.com> schreef in bericht
news:eMk9YpuVFHA.3188@TK2MSFTNGP09.phx.gbl...
> 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.
>
> "Qwert" <n***@nosp.com> wrote in message
> news:gJWdnUXtquyctx7fRVnyhQ@casema.nl...
>> 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.
>>
>>
>>
>>
>>
>
>