Results 1 to 6 of 6

Thread: How to get folder name

  1. #1

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question How to get folder name

    How do you determine what folder you are in?

    For instance, say you have a website with a few folders like this (only an example):

    www.MyWebsite.com/Cars/Imports/Volkswagen/

    What code will return the current folder, in this case, Volkswagen?
    ~Peter


  2. #2
    Big D Danial's Avatar
    Join Date
    Jul 2000
    Location
    ASP.Net Forum
    Posts
    2,877

    Re: How to get folder name

    Quote Originally Posted by MrGTI
    How do you determine what folder you are in?

    For instance, say you have a website with a few folders like this (only an example):

    www.MyWebsite.com/Cars/Imports/Volkswagen/

    What code will return the current folder, in this case, Volkswagen?

    Use Serever.MapPath(FolderPath_Or_FilePath)
    [VBF RSS Feed]

    There is a great war coming. Are you sure you are on the right side? Atleast I have chosen a side.

    If I have been helpful, Please Rate my Post. Thanks.

    This post was powered by :

  3. #3

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Question Re: How to get folder name

    I'm afraid that isn't what i was looking for. I want to get back the folder, without having to tell it what folder i'm in.
    ~Peter


  4. #4
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Re: How to get folder name

    Code:
    Dim x As DirectoryInfo = Directory.GetParent(Server.MapPath(Request.ServerVariables("SCRIPT_NAME")))
    Label1.Text = x.Name

  5. #5

    Thread Starter
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Thumbs up Re: How to get folder name

    After i added Imports System.IO to the top of the page, that code worked fine. Thanks veryjonny.

    I see it uses the Server.MapPath that Danial mentioned, only with a little more code to get the desired results!
    ~Peter


  6. #6
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    Re: How to get folder name

    I am sorry, i forgot to mention the imports stm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width