There are four types of paths available in asp.net:
1. Absolute paths
2. Relative Path
3. Root Relative Path / Absolute virtual path(another name).
4. Application Relative Path / Domain relative path(another name).
1.
Absolute Path: (We usually use this to refer external websites).
Ex: http://test/test1/test2.jpg
2.
Relative Path:
There are two types of Relative Paths.
1. client side
2. Server side
Ex: ../test1/test2.jpg
3.
Root Relative Path / Absolute virtual path: (normally used to hard code the path, not recommanded one)
Ex: /test1/test2/test3.jpg
4. A
pplication Relative Path / Domain relative path :
- comes with ~ symbol
- Normally ~ means - users home directory.
Now we will come to your problem solution. Normally if you face any problem with ~ , you can also use like this:
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "directoryname/filename.extn")
I will tell you one more interesting thing here - this ~ will work only with server side. but when you come to client side this will work with IE not with firefox.
During that time we have two kind of options (Navigateurl/Page.ResolveUrl) to use ~.
<asp:HyperLink NavigateUrl="~/yourdirectoryname/page.aspx" Text="Whatever" />
Or, use Page.ResolveUrl:
<a href="<%= Page.ResolveUrl("~/yourdirectoryname/page.aspx") %>">...</a>
HOpe this helps you.
Thanks,
Kamal
Nerdanalysis, if this helps please login to Mark As Answer. | Alert Moderator