473,399 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

How to relatively reference the path in c# asp.net

hi guys,

I have a path of eg: http://localhost/MobileShop/MobileImages but it
doesn't work if i access it removely of course.
I can do something like http://192.166.1.1/MobileShop/MobileImages ... but
it is not a better choice.

How can I reference it relatively based on the path of the application maybe
something equal to App.Path of Visual Basic.

Or any other alternative?

TA
Nov 19 '05 #1
3 2213
Hi Annie,

I'm not entirely clear what you are looking for.

Are you looking for ways to reference files in the mobile images
directory? You can use "~" as in:

<asp:Image
runat="server" ID="Image1"
ImageUrl="~/MobileImages/foo.png" />

--
Scott
http://www.OdeToCode.com/blogs/scott/
On Sat, 10 Sep 2005 23:08:28 +1000, "Annie"
<my**************@gmail.com> wrote:
hi guys,

I have a path of eg: http://localhost/MobileShop/MobileImages but it
doesn't work if i access it removely of course.
I can do something like http://192.166.1.1/MobileShop/MobileImages ... but
it is not a better choice.

How can I reference it relatively based on the path of the application maybe
something equal to App.Path of Visual Basic.

Or any other alternative?

TA


Nov 19 '05 #2
Depends on where you're trying to reference the path.

In HTML, you'll use a server-relative path:
<img src="/MobileShop/MobileImages/myimage.gif">

For runat=server controls, you can use ~/ shorthand for
application-relative paths:
<img src="~/MobileImages/myimage.gif">

For more granular control, and for manipulating files on the server,
you have all sorts of methods in the CLR to map paths. Most useful to
you is probably Server.MapPath().
Good luck!

Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 19 '05 #3
Thanks Jason. That is what i wanted. bcoz i was confused with all these
differences!
cheers!

"Annie" <my**************@gmail.com> wrote in message
news:43********@dnews.tpgi.com.au...
hi guys,

I have a path of eg: http://localhost/MobileShop/MobileImages but it
doesn't work if i access it removely of course.
I can do something like http://192.166.1.1/MobileShop/MobileImages ... but
it is not a better choice.

How can I reference it relatively based on the path of the application
maybe something equal to App.Path of Visual Basic.

Or any other alternative?

TA

Nov 19 '05 #4

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

Similar topics

2
by: Yang Liu | last post by:
Hi all, I have a .net windows application xx.exe, which reference a private assembly yy.dll, the property "local copy" of the yy.dll reference is automatically set to true, so the yy.dll will be...
0
by: Pratik Mehta | last post by:
Hi Friends, I am facing trouble with dynamically compiling C# source files. Here is the example: Following command works: csc.exe /out:test.dll /target:library...
2
by: | last post by:
I would like to add a reference to my project manually. Is there somewhere in the IDE where I can see and modify all of this project's references? Thanks, VM
2
by: Han Sen | last post by:
I have a dll that is used from word. I'd like to have an xml file with some config settings. This xml file I'd like to place in the same folder as the dll. How do I read the path of the dll form...
0
by: sonali_reddy123 | last post by:
Hi all, I have one major problem regarding how to maintain the reference paths for the projects. I have maintained the server copy which I change as my modules are finished. Then before...
3
by: mosscliffe | last post by:
I need to reference a file on my published server as "../mydir/myfile.txt", which is fine and it works. On my local develop computer the "../mydir" refers to C:\Program Files\Microsoft Visual...
2
by: DE3A10 | last post by:
How do I change my reference Path in ASPX.NET 2.0?. I already look at http://msdn2.microsoft.com/en-us/library/6taasyc6(VS.80).aspx and I din't find reference path on the properties. Can some one...
3
by: waltvw | last post by:
I'm trying to set up a value for a control on the report and part of the path should be a variable, since I have multiple objects like that. So when I try to put a variable I'm getting the "Compile...
1
by: Milancie | last post by:
We have a solution composed of managed C++, unmanaged C++, and C# dlls. All dlls wonce built reside in the same output folder The C# GUI dll has a using for the managed C++ dll and a reference...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.