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? :confused:
Use Serever.MapPath(FolderPath_Or_FilePath)
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.
Re: How to get folder name
Code:
Dim x As DirectoryInfo = Directory.GetParent(Server.MapPath(Request.ServerVariables("SCRIPT_NAME")))
Label1.Text = x.Name
Re: How to get folder name
After i added Imports System.IO to the top of the page, that code worked fine. Thanks veryjonny. :thumb:
I see it uses the Server.MapPath that Danial mentioned, only with a little more code to get the desired results!
Re: How to get folder name
I am sorry, i forgot to mention the imports stm:)