Paths in Visual Studio 2005

Last post 04-19-2007 5:48 AM by Bo Chen – MSFT. 4 replies.

Sort Posts:

  • Paths in Visual Studio 2005

    04-17-2007, 10:37 AM
    • Participant
      1,266 point Participant
    • bcanonica
    • Member since 12-08-2006, 9:11 PM
    • Fort Washington, PA
    • Posts 325

    I have been working with VS2005 for about 8 months now and I have always wondered why how come sometimes paths require a ~ in front of them and sometimes they don't.  What is the best practice when using paths so to save me work in having to go back and fix paths when they are broken.  From what I have read on it the .net engine requires a tilde and htm does not am I on the right path here or can some explain it to me in a more descriptive way?

     BC

    Remember to mark any post that is helpful as an answer and change posts status to Resolved to help others in the future.

    cheers,

    BC

    http://voidimpossible.com
  • Re: Paths in Visual Studio 2005

    04-17-2007, 2:52 PM
    Answer
    • Member
      294 point Member
    • ahsan
    • Member since 09-22-2005, 7:02 PM
    • Chicago, IL USA
    • Posts 82

    MS .net best coding practices recommend to use path starting from tilde (~). This way every page automatically track down from its base directory. This is something compiled at server side. So HTML doesn't understand. so base line. when you are doing server side development, feel free to use tilde (~) based path.

    Thank you,
     

    Ahsan Khurshid

    Tribal DDB
    Chicago IL
  • Re: Paths in Visual Studio 2005

    04-18-2007, 12:11 PM
    Answer
    • Participant
      1,465 point Participant
    • Rizwan328
    • Member since 05-25-2006, 10:26 AM
    • Dubai, UAE
    • Posts 349

    Hi,

    In my daily practice i found it best to use TemplateSourceDirectory to get the path of current directory

    in C#

    this.Templatesourcedirectory 

    in vb

    me.TemplateSourceDirectory

    then you can append the name of sub directoryes like , /images etc,

    this is really best to give path to images, and use wherever you want

    Muhammad Rizwan Javed

    Software Engineer, Mechtechnologies, Lahore, Pakistan

     

    If this post helps you, please mark it as Answer.



    Cheers,
    Muhammad Rizwan Javed
    Sr .Net Developer
    Aim 168, Dubai, UAE.
  • Re: Paths in Visual Studio 2005

    04-19-2007, 5:45 AM
    Answer

    Hi,

    The TemplateSourceDirectory property specifies the path to the page or user control that contains the current control. For example, if the Web page resides at http://www.contoso.com/application/subdirectory, the TemplateSourceDirectory property returns "application/subdirectory".

    To return the application-relative virtual path ("~/subdirectory"), use the AppRelativeTemplateSourceDirectory property.

    Just remember that tilde(~) is a server side symble and don't use it at the client side.

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: Paths in Visual Studio 2005

    04-19-2007, 5:48 AM
    Answer

    some guy has summarized different "paths" used in asp.net. you can refer to at: http://west-wind.com/weblog/posts/269.aspx

    Hope my suggestion helps :)

    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (5 items)