473,396 Members | 1,894 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,396 software developers and data experts.

How can get the current virtual path without file name?

Request.Path will get the current Path name with file name such as:
/Personal/Items.aspx

How can I get the only Path name such as:
/Personal

Nov 19 '05 #1
10 16889
Try HttpRequest.ApplicationPath

Alex
http://www.DotNet42.com - The Answer to Your .NET Question

"farmer" <sd******@sina.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Request.Path will get the current Path name with file name such as:
/Personal/Items.aspx

How can I get the only Path name such as:
/Personal

Nov 19 '05 #2
with vb, Left(Request.Path.LastIndexOf("/"))

Nov 19 '05 #3
Have you tried Request.ApplicationPath ?
"farmer" wrote:
Request.Path will get the current Path name with file name such as:
/Personal/Items.aspx

How can I get the only Path name such as:
/Personal

Nov 19 '05 #4
Request.ApplicationPath return current Appliction's root virtual
Path,not the path one page belongs to.

Wizard04's solution may make sense,I will try,thanks very much~

Nov 19 '05 #5
Sorry Alex,HttpRequest.ApplicationPath makes no sense.

Nov 19 '05 #6
Ok...but not so graceful.The much important thing is:is it reliable
enough for any URL pattern?

Nov 19 '05 #7
What you are looking for is Page.TemplateSourceDirectory

VB.NET :
Dim currentDir As String = Page.TemplateSourceDirectory

C# :
string currentDir = Page.TemplateSourceDirectory;

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"farmer" <sd******@sina.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Sorry Alex,HttpRequest.ApplicationPath makes no sense.

Nov 19 '05 #8
See my just-sent reply...

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"farmer" <sd******@sina.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Ok...but not so graceful.The much important thing is:is it reliable
enough for any URL pattern?

Nov 19 '05 #9
I am using C#,this makes sense:
string
ThisPath=HttpContext.Current.Request.Path.Substrin g(0,HttpContext.Current.Request.Path.LastIndexOf("/"));

Nov 19 '05 #10
Great!
So lovely Juan T. Llibre! :-D

Nov 19 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Saracen | last post by:
I have a major problem with trying to access a foxpro database from a web app. I have created a web app which is deployed on a server. The foxpro database (dbf) is on a different server. The...
0
by: John Clark | last post by:
Hi, I am using webbrowser control to automate a site. this site contains form with tage <INPUT TYPE=FILE ...> I know the control is not writeable. So, only thing that I could do was: ...
2
by: markryde | last post by:
Hello, I am trying to add the current date to a file name in python script like thus: import os import sys import rpm import time import datetime
1
by: MikeD | last post by:
Hi, I'm accessing a FoxPro database via ole db using Reporting Services Data Extensions and ths works fine on my local report server. However, when I deploy the report to the live report server...
2
by: freak | last post by:
Sorry , corrections to my script Have a problem with spaces in the function popen Next example works fine: ... $drive="c:"; $path=""; $file="\\myfile.exe"">"; $call = $drive.$path.$file;...
18
by: walterbyrd | last post by:
I am trying to develop an app where: the same file, in the same place, will be uploaded, and then processed. Everything I can find about uploading a file, uses a form that requires the user to...
0
by: kamath10 | last post by:
Hi, Consider a scenario where there are a couple of notepads open say temp1.txt and temp2.txt. How do i programmatically get their full path name? regards Raghu
5
by: cssExp | last post by:
alright suppose i have the following. <input type="file" name="upload" /> <input type="text" name="discription" /> <input type="image" onclick="addFile();" src="images/addfile.jpg" name="add"...
1
by: mastro78 | last post by:
I'm using 2002 I defined my recordset as rWrkSheet Spreadsheet is the field in table Spreadsheets PathToExcelFiles is the full path where the Excel files i'm ref is stored ExcelFileName is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.