current directory of WebForm ?

Discussion in 'ASP .Net' started by Chris, Apr 24, 2004.

  1. Chris

    Chris Guest

    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
    Chris, Apr 24, 2004
    #1
    1. Advertising

  2. Chris

    Scott Allen Guest

    You can use the static method GetDirectoryName of the Path class in
    System.IO.

    ie:

    System.IO.Path.GetDirectoryName(Request.PhysicalPath));


    HTH,

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

    On Sat, 24 Apr 2004 13:04:52 GMT, "Chris" <>
    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
    >
    Scott Allen, Apr 24, 2004
    #2
    1. Advertising

  3. Chris

    clintonG Guest

    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
    URL http://www.metromilwaukee.com/clintongallagher/



    "Chris" <> wrote in message
    news:UBtic.84735$-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
    >
    >
    clintonG, Apr 24, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. titof
    Replies:
    0
    Views:
    472
    titof
    Jul 24, 2003
  2. timmso
    Replies:
    1
    Views:
    460
    Alex Papadimoulis
    Dec 12, 2003
  3. =?Utf-8?B?bXN1aw==?=

    Using one webform to set a value on another webform

    =?Utf-8?B?bXN1aw==?=, Jul 12, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    430
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Jul 12, 2006
  4. =?Utf-8?B?Vk1J?=

    Moving value from popup Webform to main Webform?

    =?Utf-8?B?Vk1J?=, Oct 9, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    541
    GroupReader
    Oct 9, 2006
  5. Luqman
    Replies:
    2
    Views:
    644
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Apr 11, 2007
Loading...

Share This Page