473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

How can I get my /directory/ name?

bencoding
Hello, I am building a "Web App" in "Visual Web Developer 2005" and need to be able to read my directory, for example http://mywebapp.com/dirname/Default.aspx

So how would I be able to read the current directory name which in this case is "dirname"
Jun 25 '08 #1
6 1606
Curtis Rutland
3,256 Expert 2GB
I'm not entirely sure what you mean by "read my directory."

If you want to get the physical address of a relative path, you can use Server.MapPath("relPath")

If you need to read all the files in the directory or something like that, you can use the System.IO.DirectoryInfo object to do many things like that.
Jun 25 '08 #2
Ok, I can probably clarify that, ....I would like to get the directory or folder name so that I can use it in my code, for example if the directory name is /projects/Default.aspx

I would write some code like

if (directory name = 'projects')
{
// do something here
}

So I would like to be able to get the directory name to use in my code, and for testing purposes I am using Response.Write(); to see if it works. I appreciate that code you gave me but is showing me too much data, I would just like the directory name.



I'm not entirely sure what you mean by "read my directory."

If you want to get the physical address of a relative path, you can use Server.MapPath("relPath")

If you need to read all the files in the directory or something like that, you can use the System.IO.DirectoryInfo object to do many things like that.
Jun 25 '08 #3
Plater
7,872 Expert 4TB
Have you tried:
Server.MapPath(".") ?
Jun 25 '08 #4
I just tried Server.MapPath(".") and it's closer to what I need, it gives me

C:\Program Files\CCM\Projects

... I would need to extract "Projects" some how, if this is the closest I can get could I use a string function to strip everything out up to the 3rd "\" ?


Have you tried:
Server.MapPath(".") ?
Jun 25 '08 #5
Curtis Rutland
3,256 Expert 2GB
I just tried Server.MapPath(".") and it's closer to what I need, it gives me

C:\Program Files\CCM\Projects

... I would need to extract "Projects" some how, if this is the closest I can get could I use a string function to strip everything out up to the 3rd "\" ?
Use the .Split(delimiter) method.
Expand|Select|Wrap|Line Numbers
  1. //c# code, I don't know what language you use.
  2. string path = Server.MapPath(".");
  3. char[] delim = { '\\' };
  4. string[] tokens = path.Split(delim);
  5. string folder = tokens[tokens.Length-1];
  6. //now folder has "Projects"
  7.  
Jun 25 '08 #6
thanks guys!....................
Jun 25 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: jajoo | last post by:
Hi everyone, I am trying to send files with multipart/form-date. Everything is ok with the send. But when I am receiving the files I should specify a directory where the files to be saved. The...
8
by: Glenn A. Harlan | last post by:
Why am I receiving the below error when calling - Path.GetTempFileName() The directory name is invalid. Description: An unhandled exception occurred during the execution of the current web...
1
by: Dennis | last post by:
Hi, I am wondering that the Application Name in Virtual Directory is compulsory be non-empty field when configuring Virtual Directory for ASP.NET application? I realized some of my ASP.NET...
8
by: James Owens | last post by:
I'm a relative newbie, interested in storing the information from several server directories and subdirectories in XML so that I can present it selectively using XSL (all files updated today or...
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
5
by: Bas Hendriks | last post by:
Has anyone any idea how asp.net find it's files back after compiling them to the temporary asp.net directory? I found on numerous webpages that the directorynames are chosen random but cannot find...
27
by: Javier Martinez | last post by:
Hi I have asp application in a machine with a virtual directory referring a shared directory in another machine When I try to load any aspx page of my portal I get the following error: ...
6
by: dave | last post by:
I really have 2 questions regarding the following xml snippet. The xml is a directory representation. <?xml version="1.0" standalone="yes"?> <FileSystem> <Row> <ID>1</ID> <Name>Root</Name>...
28
by: Peter Oliphant | last post by:
I have written a program using MS VS VC++ 2005 Express, /cli pure. Upon compiling it it works fine in the GUI development environment. It also works fine as a Debug stand-alone. ut I had an odd...
6
by: falconsx23 | last post by:
I am trying to write a code for a Phone Directory program. This program is suppose to allow the user to enter a name or directory and then program can either add, save or even delete an entry. Also...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.