How to get current folder path?

Discussion in 'ASP .Net' started by Chung, Nov 17, 2003.

  1. Chung

    Chung Guest

    Hi,

    I am developing an asp.net application. I have create
    some class method and I would like to get the folder path
    of that class method. I cannot use this.Mappath("") to get
    the path because it is not a type of *.aspx.cs. I try to
    use System.Environment.CurrentDirectory() but it return
    c:\winnt\system32 when I use
    System.Web.HttpContext.Current.Server.MapPath("") it
    returns path from the aspx file that call the class method.

    I hope someone can help me on my problem.

    Chung
    Chung, Nov 17, 2003
    #1
    1. Advertising

  2. System.Assembly.Location will give you the file system path to the assembly.
    The assembly itself sits in the bin directory of the application root, which
    you can also get. The cs file exists only in development. (Well, you could
    copy it to production, but that's not a good idea.)

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows Shell/UI
    Windows XP Associate Expert
    --
    More people read the newsgroups than read my email.
    Reply to the newsgroup for a faster response.
    (Control-G using Outlook Express)
    --

    "Chung" <> wrote in message
    news:083501c3ad0a$ebc350b0$...
    > Hi,
    >
    > I am developing an asp.net application. I have create
    > some class method and I would like to get the folder path
    > of that class method. I cannot use this.Mappath("") to get
    > the path because it is not a type of *.aspx.cs. I try to
    > use System.Environment.CurrentDirectory() but it return
    > c:\winnt\system32 when I use
    > System.Web.HttpContext.Current.Server.MapPath("") it
    > returns path from the aspx file that call the class method.
    >
    > I hope someone can help me on my problem.
    >
    > Chung
    >
    Chris Jackson, Nov 17, 2003
    #2
    1. Advertising

  3. Chung

    Nazer

    Joined:
    Jan 20, 2008
    Messages:
    1
    what about having a property in that class to return its current folder?
    Last edited: Jan 20, 2008
    Nazer, Jan 20, 2008
    #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. PHaroZ
    Replies:
    5
    Views:
    94,787
    akash02sap
    Aug 17, 2012
  2. Eranga Udesh

    Howto get the current file path with SSI

    Eranga Udesh, Apr 5, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,091
    Aaron Bertrand [MVP]
    Apr 6, 2004
  3. Olav Tollefsen

    How to get directory path of current rquest?

    Olav Tollefsen, Oct 29, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,207
    Scott Mitchell [MVP]
    Oct 29, 2004
  4. farmer
    Replies:
    10
    Views:
    33,298
    farmer
    Oct 25, 2005
  5. bala
    Replies:
    2
    Views:
    104
    Nikola Stjelja
    Feb 27, 2008
Loading...

Share This Page