DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2005
    Posts
    111

    Relative path of folder

    Hi,

    This perhaps is a simple question, but it takes me almost a day to think about the solution. Would anyone give me a solution?

    In my development server, the IIS points to a root and the folder structure look likes this:
    Root
    Folder 1 (under Root)
    Folder A, Folder B (both under Folder 1)
    Folder C, Folder D (both under Folder A)
    a banner.ascx contains an image from Folder B, so I code in it "/Folder1/Folder B/pic1.jpg"

    In my production server, the structure is a bit different:
    Root
    Folder A, Folder B (both under Root)
    Folder C, Folder D (both under Folder A)

    Therefore, when I move all web pages from development server to production, I need to change every path from "/Folder1/Folder B" to "../Folder B/" . I think this is not a good way to modify the path here and there, but how can I move the pages without changing the path ?

    Please help me!!!!!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Create a new virtual directory on your development server and make it the root folder of your application. So, instead of http://localhost/Folder1, the root becomes http://virtualdir/. You will be able to use the same code on your dev and production servers.

    You may also find this technique helpful: http://www.aspnetpro.com/newslettera...200311kd_l.asp
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Aug 2005
    Posts
    111
    Thanks Phil Weber again,

    It seems that the virtual directory is feasible, but when I create another project, it requires to change the virtual directory again. That makes it quite complicated. However, I have read the article you show me, but the Tilde character could not work on the web page, I change the image URL to "~/Folder B/pic.jpg", but the picture doesn't load.

    At last, I find in the article mentions the "../../" notation and I use it to modify the URL to "../../Folder B/pic.jpg", it works on both development and production server !!!! : )

    So, I decide to use this notation.

  4. #4
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    The tilde character only works for server controls. So, for example, if you want to use it in an HTML <img> tag, you must include a runat="server" attribute.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. Relative path for loading file
    By tomz2000 in forum VB Classic
    Replies: 8
    Last Post: 09-27-2007, 07:38 PM
  2. Absolute path vs Relative path
    By Max25 in forum Java
    Replies: 4
    Last Post: 09-19-2005, 01:44 AM
  3. Replies: 2
    Last Post: 11-12-2000, 02:51 AM
  4. Replies: 2
    Last Post: 06-08-2000, 01:40 PM
  5. Replies: 0
    Last Post: 06-07-2000, 12:29 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links