473,513 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Starting question: picture location.

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.

Nov 19 '05 #1
3 934
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.

"Qwert" <no**@nosp.com> wrote in message
news:gJ********************@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.


Nov 19 '05 #2
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" <no**@nosp.com> wrote in message
news:gJ********************@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.


Nov 19 '05 #3
Thanks both, it gets the correct location.
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> schreef in bericht
news:eM**************@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" <no**@nosp.com> wrote in message
news:gJ********************@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.



Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

40
1843
by: Geoff Cox | last post by:
Hello, The following code works with document.getElementById('picture').src = window.src; but not if I increase the index to 1, ie document.getElementById('picture').src = window.src;
10
3204
by: mattmerc | last post by:
Hi all, I posted this about a week back with no response so I want to try again. I have a weird questions in regards to working with sql image data types. I know how to take the image type and convert it into a picture on the screen. What I have is a situation where I need to read the image data from one database, store it, and then upload...
2
1229
by: Woody Splawn | last post by:
I just wondering if rather than keeping a database with pictures of employees in it (like a photo field), I'm wondering if instead you could just keep the picture files in your bin directory of a project, and call them in real time as you move from record to record on a winform? Is this possible? Is this preferable to having to duplicate the...
1
1564
by: nowitsoverx | last post by:
I'm just trying to test something out to see if I can get it working but I'm a little stuck. I have two frames. The left one has a menu of radio buttons. I want it so when you click on the radio button it will show the picture in the right frame. When you click on a different radio button I want it to show that picture to the right of the...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.