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

current directory of WebForm ?

Hi,

how can I obtain the name of the directory where my aspx-file is located ?

I tried :
string str = Directory.GetCurrentDirectory();
DirectoryInfo dir = new DirectoryInfo(str);

but Directory.GetCurrentDirectory() returns "C:\WinNt\System32" whereas my
current aspx-file is located in "C:\Inetpub\wwwroot\PersonalWebSite"

Thanks

Chris
Nov 18 '05 #1
2 1913
You can use the static method GetDirectoryName of the Path class in
System.IO.

ie:

System.IO.Path.GetDirectoryName(Request.PhysicalPa th));
HTH,

--
Scott
http://www.OdeToCode.com

On Sat, 24 Apr 2004 13:04:52 GMT, "Chris" <ch********@pandora.be>
wrote:
Hi,

how can I obtain the name of the directory where my aspx-file is located ?

I tried :
string str = Directory.GetCurrentDirectory();
DirectoryInfo dir = new DirectoryInfo(str);

but Directory.GetCurrentDirectory() returns "C:\WinNt\System32" whereas my
current aspx-file is located in "C:\Inetpub\wwwroot\PersonalWebSite"

Thanks

Chris


Nov 18 '05 #2
lblMapPath.Text = Server.MapPath("filename.aspx").ToString();
--
<%= Clinton Gallagher
A/E/C Consulting, Web Design, e-Commerce Software Development
Wauwatosa, Milwaukee County, Wisconsin USA
NET cs*********@REMOVETHISTEXTmetromilwaukee.com
URL http://www.metromilwaukee.com/clintongallagher/

"Chris" <ch********@pandora.be> wrote in message
news:UB*********************@phobos.telenet-ops.be...
Hi,

how can I obtain the name of the directory where my aspx-file is located ?

I tried :
string str = Directory.GetCurrentDirectory();
DirectoryInfo dir = new DirectoryInfo(str);

but Directory.GetCurrentDirectory() returns "C:\WinNt\System32" whereas my
current aspx-file is located in "C:\Inetpub\wwwroot\PersonalWebSite"

Thanks

Chris

Nov 18 '05 #3

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

Similar topics

3
by: Daniel | last post by:
How do you get the current directory of the actual .exe file (not the file name but the directory it is in) ? These do not work: System.IO.Directory.GetCurrentDirectory() - returns system...
1
by: Islam Elkhayat | last post by:
How can i get my current Namespace & current class in my webform... I tried alot but i get ASP.myformname_aspx... Is there a way to get Current Namespace, class??
1
by: Tony | last post by:
I'm porting an old Coldfusion based content and asset management system to ASP.NET (and oh, how good it feels to write REAL code again - was a C++ hack for 10 years, started doing coldfusion about...
2
by: Michael Mayer [C# MVP] | last post by:
I want to create a "virtual" directory (not and IIS virtual directory, which really seems to just be a link to a real directory) where the contents of that directory can be read from a database. ...
4
by: Kristof Despiere | last post by:
Suppose you have one domain, filled with a couple of users. What needs to be done now is I need to start a windows application from a webform by pressing a button on the webform (for example). ...
4
by: Nick | last post by:
I'm developing an intranet app, and want to get the current user name for logging purposes. I've turned off anonymous access, and turned on windows authentication in the IIS config. The apps...
5
by: MilanB | last post by:
Hello, I have images in local server directory. Can I stream down image into HTML WebForm, on place reserved to specific image, and show to clients. I wish to avoid coping images to virtual...
3
by: Chris Mellon | last post by:
This appears to be a change in behavior from Python 2.4 to Python 2.5, which I can't find documented anywhere. It may be windows only, or related to Windows behavior. In 2.4, the current...
2
by: Luqman | last post by:
How can I open another WebForm in ASP.Net / VS 2005 without closing the Current Webform. I tried using Server.Transfer("Form2.Aspx",True) on Button_Click of Form1 but it close the current web...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.